LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Syntax to Set variable range

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting a range of rows based on a variable; syntax error Babymech Excel Discussion (Misc queries) 3 January 16th 09 06:19 PM
macro syntax for selecting variable range Matt Excel Discussion (Misc queries) 1 October 31st 07 07:13 PM
SaveAs syntax when using a variable Keith Excel Programming 3 November 4th 03 05:48 PM
Syntax for variable search brym Excel Programming 0 August 6th 03 05:41 PM
Syntax for variable search brym Excel Programming 2 August 6th 03 05:32 PM


All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"