Solved

Copy Paste Error Using RefEdit Control VBA Excel

Posted on 2016-08-31
3
31 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
Comment Utility
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 48

Accepted Solution

by:
Rgonzo1971 earned 250 total points
Comment Utility
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
Comment Utility
Thank you.  Putting the Copy command in the OK code worked. A Happy chappie!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
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…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now