Thread: Range question
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson[_3_] Jim Thomlinson[_3_] is offline
external usenet poster
 
Posts: 983
Default Range question

This might be a little funkier than you wanted but here goes...

copy everything below here to a new workbook module

'This function will set a range
public function GetRange (byval strSheetName as string, byval lngFirstRow as
long, byval lngLastRow as long) as range

set GetRange = sheets(strsheetname).range(lngFirstRow & ":" & lngLastRow)

end function

'Now to use the function...
sub test
dim rngMyRange as range

set rngmyrange = getrange("Sheet1", 3, 10)

'Now you have a range object with all the associated properties and methods.

rngMyRange.Select

end sub

'Hope this helps...

"strataguru" wrote:


Hi,

I'd like to select a Range in column 1 from Row 1 to 7. Another time
it may be some other random column for a difference range of rows.

So I'm wondering - how can I numerically select a range. I can't use
hard coded values like:

Range("A1:A7").Select

How can I select my Range dynamically for a ad-hoc group of cells?

Thanks in advance


--
strataguru
------------------------------------------------------------------------
strataguru's Profile: http://www.excelforum.com/member.php...fo&userid=1313
View this thread: http://www.excelforum.com/showthread...hreadid=263374