selection end to end range in vba

mrinal saha

Board Regular
Joined
Jan 20, 2009
Messages
229
Hi Folks,


In the below code, I'm trying to get the rownumber of the cell containg "CONTROL NO". And than want to select the entire range from that cell to lr and lc. But selection is a problem statement for me now. need a line for that.


lr = ActiveSheet.UsedRange.Rows.Count
lc = ActiveSheet.UsedRange.Columns.Count

For i = 1 To 7
If Cells(i, 1).Value = "CONTROL NO" Then
rownum = Cells(i, 1).Row
End If
Next i


Cells(rownum, lc).Select

Thanks,
Mrinal
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Code:
range(range("A1:A7").find("CONTROL NO"),cells(lr,lc)).select
perhaps

or replace the whole code with

Code:
Range(Range("A1:A7").Find("CONTROL NO"), Cells.SpecialCells(xlCellTypeLastCell)).Select

You know that you don't always need to 'select' cells in order to do things with them?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,552
Messages
6,179,487
Members
452,917
Latest member
MrsMSalt

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