M
Mike Fogleman
I can't seem to nail the syntax to set a range from two cells.
Excerpt:
Option Explicit
Public prng As Range
Sub USFilter()
Dim a As String, b As String, vl As String
Dim rw As Long
Dim drng As Range, xrng As Range, c As Range
Set drng = Worksheets("US Analysis").Range("H1")
'...some other code
rw = Cells(Rows.Count, drng.Column).End(xlUp).row
a = drng.Offset(1, -1).Address
b = drng.Offset(rw - 1, -1).Address
Set xrng = Range("a:b") 'can't get this right
For Each c In xrng
vl = c.Offset(0, 1)
c.Value = WorksheetFunction.VLookup(vl, prng, 2, False)
Next c
End Sub
The VLookup works fine if I set the xrng manually. The reference to drng
will change each time this sub is ran according to ...some other code.
Any input would be appreciated.
Thnx Mike F
Excerpt:
Option Explicit
Public prng As Range
Sub USFilter()
Dim a As String, b As String, vl As String
Dim rw As Long
Dim drng As Range, xrng As Range, c As Range
Set drng = Worksheets("US Analysis").Range("H1")
'...some other code
rw = Cells(Rows.Count, drng.Column).End(xlUp).row
a = drng.Offset(1, -1).Address
b = drng.Offset(rw - 1, -1).Address
Set xrng = Range("a:b") 'can't get this right
For Each c In xrng
vl = c.Offset(0, 1)
c.Value = WorksheetFunction.VLookup(vl, prng, 2, False)
Next c
End Sub
The VLookup works fine if I set the xrng manually. The reference to drng
will change each time this sub is ran according to ...some other code.
Any input would be appreciated.
Thnx Mike F