Selecting a changing area

BillLambeer

Board Regular
Joined
Jan 14, 2003
Messages
51
321BB_dec02.xls
ABCDEFGHIJKLMNOPQRS
12001/082001/092001/102001/112001/122002/012002/022002/032002/042002/052002/062002/072002/082002/092002/102002/112002/12Average
2Month0
3Month111142
4Month2181322
5Month31151231
6Month414642543
7Month51642453522
8Month6172353331
9Month7522242611
10Month863425134
11Month933411324
12Month102215713
13Month11216982
14Month12169141
15Month137111
16Month14111
Reliability

I have the above spreadsheet and I need to select B2:R16 in this case. B2 is always the fist cell and 16 is always the last row. However the column changes as I add months and I'm not sure how to find the end. What I do is select the whole range and paste a VLOOKUP formula in. Then I replace all of the #N/A with "" so the other formulas will work. As you can see there is not always data in the current month so I can't use

Range("B2", Range("B16").End(xlRight)).Select

Please ask me if you need any clarification. Thanks this board is great.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
if you're doing this in VB then first do

Cells(1,1).select
COL = Cells.End(xlRight).Column
RW = Cells.End(xlDown).Row

then your range will be

Range(Cells(2,2),Cells(RW,COL)) = "=vlookup..."
 
Upvote 0
On 2003-01-24 10:59, lasw10 wrote:
if you're doing this in VB then first do

Cells(1,1).select
COL = Cells.End(xlRight).Column
RW = Cells.End(xlDown).Row

then your range will be

Range(Cells(2,2),Cells(RW,COL)) = "=vlookup..."

I could not get the above code to work. It gave me an error on the line where COL is set to the last column. I have been experimenting a bit with the code below.

With Worksheets("Reliability").Range("A1:EZ1")
Set c = .Find("Average", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Select
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With


ActiveCell.Offset(rowOffset:=15, columnOffset:=-1).Activate
ED = ActiveCell.Column
Range(Cells(2, 2), Cells(16, ED)).Select

Does this code seem like it will work?
 
Upvote 0

Forum statistics

Threads
1,216,092
Messages
6,128,782
Members
449,468
Latest member
AGreen17

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top