talkinggoat
New Member
- Joined
- Feb 1, 2022
- Messages
- 33
- Office Version
- 365
- Platform
- Windows
I found the thread below, which works great, but I need to modify it to incorporate a variable range. In other words, my source range length will always change.
I know I can use the following to determine the number of rows and columns, but how would I apply that to the source document? Sometimes I might need to select 300 lines, sometimes 30 or maybe 5 columns today and 9 tomorrow, depending on the document.
Use VBA to open file dialog and copy paste into current worksheet
Hello all, I am attempting to write a VBA to input data into a sheet I am working on. I am trying to input data into a spreadsheet that is currently set up so I need to paste data into the range D2:D195 in the current sheet. I would like to create a button that would allow me to pick a file...
www.mrexcel.com
I know I can use the following to determine the number of rows and columns, but how would I apply that to the source document? Sometimes I might need to select 300 lines, sometimes 30 or maybe 5 columns today and 9 tomorrow, depending on the document.
VBA Code:
'// Determine the number of columns.
lcol = Cells.Find(what:="*", _
after:=Range("a1"), _
lookat:=xlPart, _
LookIn:=xlFormulas, _
searchorder:=xlByColumns, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Column
VBA Code:
'// Determine number of rows
lrow = Cells.Find(what:="*", _
after:=Range("a1"), _
lookat:=xlPart, _
LookIn:=xlFormulas, _
searchorder:=xlByRows, _
SearchDirection:=xlPrevious, _
MatchCase:=False).Row