I am trying to make a macro that selects certain data on my worksheet. I have a sheet with data that gets pulled into it using:
Windows("Item checkout workbook_New.xlsx").Activate
Range("A2:G300").Select
Selection.Copy
Windows("VLookup test.xlsx").Activate
Sheets("Sheet1").Select
Range("A2:G2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Sheets("Sheet1").Range("A2:G300").Copy Sheets("Sheet2").Range("A2")
Sheets("Sheet2").Select
Application.CutCopyMode = False
After entering this data, I have two columns H2:H300and I2:I300, which already have formulas for Vlookup, which get the information from A2:G300.
Then I need to select only the relevant data and copy it back to Windows("Item checkout workbook_New.xlsx"). For relevant data, I need to select only cells with data in the range A2:G300, as well as cells H2:I300that match. Having seen that ALL cells H2:I300have data, I'm not sure how to do this. I tried to create a macro that uses END to select the entire column A, and then the rows that go with it, but this is what I got, and as you can see, this will not work:
Range("A2").Select
Range(Selection, Selection.End(xlDown)).Select
Range("A2:I78").Select
Selection.Copy
I'm not very good at VBA, so it's hard to figure things out on the fly, but I feel that there must be a way to make this work. Any advice would be great!
source
share