Thread: Vatiable range
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Mike Fogleman Mike Fogleman is offline
external usenet poster
 
Posts: 1,092
Default Vatiable range

To supplement Norman's code to work with unknown column numbers also:

Public Sub Tester()
Dim SH As Worksheet
Dim Rng As Range
Dim iRow As Long
Dim iCol As Long

Set SH = ActiveSheet '<<==== CHANGE
iCol = Cells(2, Columns.Count).End(xlToLeft).Column
With SH
iRow = .Range("B" & Rows.Count).End(xlUp).Row

Set Rng = .Range((Cells(2, 2)), (Cells(iRow, iCol)))
Rng.Name = "Databse"
End With
End Sub

Mike F
"Oldjay" wrote in message
...
I need to expand or reduce a range named "Database
I need to use (I guess) OffSet to select 4 adjacent col's

I started with this

Range("B6").Select
Range(Selection, Selection.End(xlDown)).Select
Range("Database").CurrentRegion.Name = "Database"

How do I do this?

oldjay