Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Copy Paste Error Using RefEdit Control VBA Excel

Posted on 2016-08-31
3
Medium Priority
?
117 Views
Last Modified: 2016-08-31
I want to delete and reorder columns in a downloaded csv file, then copy the remaining data into a sheet in another, master workbook.

Procedure:
Open both attached spreadsheets
With The Sample_PASTE_FROM workbook active, CTRL+SHIFT+S to run the macro
With the Ref edit user-form, click Range("A2") in the Sample_PASTE_TO spreadsheet

I have succeeded right up until the Copy and paste command.

This is the code from the Ref edit Userform OK click command
Private Sub cmd_OK_Click()
'This will paste the copied data from the Braintree
' Settlement Batch Summary Report
'-------
'Declare Variables
    Dim rBraintree As Range     'First Cell in Braintree tab to paste info.
    Dim strAddress As String    'Ref Edit address
'-------
'Address of paste area from refedit control
    strAddress = ref_Recon.Value
'Set Paste Range
    Set rBraintree = Range(strAddress)
'Activate the second workbook to paste the data
    rBraintree.Parent.Activate
'Select the paste destination cell
    rBraintree.Select
'Paste the data
    ActiveSheet.Paste
'Reset the ref_Recon refedit control
    Unload Me

End Sub

Open in new window


It seems that the CutCopyMode does not remain active when passing from the module with the code to the Userform.

Can someone help, please?

Thanks very much
David Phelops
Sample_PASTE_TO.xlsx
Sample_PASTE_FROM.xlsm
0
Comment
Question by:David Phelops
3 Comments
 
LVL 35

Assisted Solution

by:[ fanpages ]
[ fanpages ] earned 1000 total points
ID: 41777993
Why don't you place the Copy statement within the OK event code, prefixing/fully-qualifying as follows?...

ThisWorkbook.ActiveSheet.Cells(1, 1).CurrentRegion.Offset(1, 0).Copy.Cells(1, 1).CurrentRegion.Offset(1, 0).Copy
1
 
LVL 53

Accepted Solution

by:
Rgonzo1971 earned 1000 total points
ID: 41777994
Hi,

pls try
Private Sub cmd_OK_Click()
'This will paste the copied data from the Braintree
' Settlement Batch Summary Report
'-------
'Declare Variables
    Dim rBraintree As Range     'First Cell in Braintree tab to paste info.
    Dim strAddress As String    'Ref Edit address
'-------
'Address of paste area from refedit control
    strAddress = ref_Recon.Value
'Set Paste Range
    Set rBraintree = Range(strAddress)
'Activate the second workbook to paste the data
    rBraintree.Parent.Activate
'Select the paste destination cell
    rBraintree.Copy
'Paste the data
    ActiveSheet.Paste
'Reset the ref_Recon refedit control
    Unload Me

End Sub

Open in new window

Regards
1
 

Author Closing Comment

by:David Phelops
ID: 41778018
Thank you.  Putting the Copy command in the OK code worked. A Happy chappie!
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

963 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question