belle_the_cat
New Member
- Joined
- Jun 23, 2021
- Messages
- 7
- Office Version
- 365
- 2013
- Platform
- Windows
- MacOS
Hi guys,
I want to name two ranges without using select, but I'm totally stuck. This is part of a longer macro so I'm just pasting the relevant bits.
This is what I'm trying to do, but without selecting:
The length of the list will vary, and I've already got a variable for the last row, I tried doing this:
Which didn't work, presumably because I'm a huge idiot.
I keep looking at this thread, and I feel like it contains the answer, but I can't seem to figure out how to put it into practice.
Any help would be extremely appreciated!
I want to name two ranges without using select, but I'm totally stuck. This is part of a longer macro so I'm just pasting the relevant bits.
This is what I'm trying to do, but without selecting:
VBA Code:
Range("A:B").Select
Range(Selection, Selection.End(xlDown))
Selection.Name = "importLookup"
Range("A:A").Select
Range(Selection,Selection.End(xlDown))
Selection.Name = "importNames"
The length of the list will vary, and I've already got a variable for the last row, I tried doing this:
Code:
Dim lrImport as Long
lrImport = Worksheets("Import").Range("A" & Rows.Count).End(xlUp).Row
Range("A:A" & lrImport).Name = importLookup
Range("A:B" & lrImport).Name = importNames
Which didn't work, presumably because I'm a huge idiot.
I keep looking at this thread, and I feel like it contains the answer, but I can't seem to figure out how to put it into practice.
Any help would be extremely appreciated!