Aznflipfoo
New Member
- Joined
- Nov 5, 2016
- Messages
- 1
Hey guys so I'm pretty beginner at VBA and have been working on making a macro with VBA to extract some data from a different workbook than the current one that starts the macro.
So right now this is the code that I have:
A little bit of info on the workbook I'm pulling data from. The workbook is updated every week and can vary in amount of rows used, so the code has to account for this.
Essentially the two problems I've gotten are this:
I've been working on this for a couple of weeks tweaking my code to get to this point (i know it's sorry, but this is hard stuff for me), and I've been stuck at these two points for a while. Keep in mind I might have a hard time understanding some of your code/replies if it's too complex for me, but I will try to work through it as I have taken some CS courses before.
So right now this is the code that I have:
Code:
Sub Macro8()
Dim fd As FileDialog
Dim OpenOrder As String
Dim MacroBook As String
Dim LR As Long
MacroBook = ActiveWorkbook.Name
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.AllowMultiSelect = False
fd.Show
Workbooks.Open fd.SelectedItems(1)
OpenOrder = ActiveWorkbook.Name
ActiveSheet.Range("$A$1:$X$33646").AutoFilter Field:=2, Criteria1:= _
"6157 - Las Vegas Premium North"
LR = ActiveSheet.Range("L" & Rows.Count).End(xlUp).Row
Range("L" & LR).SpecialCells(xlCellTypeVisible).Select
' Not sure how to copy the above selection to the original workbook (MacroBook)
Windows(OpenOrder).Close SaveChanges:=False
End Sub
A little bit of info on the workbook I'm pulling data from. The workbook is updated every week and can vary in amount of rows used, so the code has to account for this.
Essentially the two problems I've gotten are this:
- When using the find last row method, and then selecting an entire visible column, sometimes the selection gets cut off at about 30k rows and nothing below that gets selected. Not entirely sure why.
- The most important part of this code that I'm having trouble with, is actually selecting or copy/pasting the result of a column (only visible cells) and not having the entire used worksheet being selected/copied.
I've been working on this for a couple of weeks tweaking my code to get to this point (i know it's sorry, but this is hard stuff for me), and I've been stuck at these two points for a while. Keep in mind I might have a hard time understanding some of your code/replies if it's too complex for me, but I will try to work through it as I have taken some CS courses before.