Solved

Copy Paste Error Using RefEdit Control VBA Excel

Posted on 2016-08-31
3
61 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 250 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 50

Accepted Solution

by:
Rgonzo1971 earned 250 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

860 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