Hello,
I'm brand new to VBA and have hobbled together some code but am having an issue.
The goal is to copy a range of data from a table in a workbook and paste the range into cell A2 of a worksheet inside a different workbook.
Both workbooks are stored in my One Drive > Documents folder.
The code I currently have works with the exception being that it pastes the data into cell B2 rather than cell A2.
Here's my current code:
Sub CopyData()
MIE = ThisWorkbook.Path & Application.PathSeparator & "MIE.xlsx"
Dim wk As Workbook
Set wk = Workbooks.Open(MIE, ReadOnly:=True)
Dim rgSource As Range, rgDestination As Range
Set rgSource = wk.Worksheets("Transactions").Range("A7:F12")
Set rgDestination = ThisWorkbook.Worksheets("Import").Range("A2")
rgSource.Copy
rgDestination.PasteSpecial xlPasteValues
End Sub
I have looked all over to find a solution to this issue but can't figure this out. Any help is greatly appreciated.
The range to copy will change every time I use it so I will just adjust the range in the VBA code until I become better at VBA, at which point in time I'd love to have VBA ask me to select a range and then it would run the rest of the code.
Once I have this issue resolved, I still have three other task to automate with the newly pasted data.
1.) One of the columns has negative numbers that need to be converted to positive numbers (so I'll need to select a range and multiply by -1)
2.) One of the columns is a date and I'd like to sort everything that was pasted into this workbook from oldest to newest
3.) Then I need to run a find/replace on text in one of the columns.
If there are any resources or code example you can share to help with these other three issues I would love to learn.
Thank You in advance for any and all assistance! I appreciate it!
Ben
Bookmarks