selecting the last used cell in a column

navyaa

Board Regular
Joined
Jul 7, 2002
Messages
223
I have to select 4 columns till the last cell that has a value. I start selecting at cell B4 and have to select C4,D4 and E4 but only till the last used cell.

I tried using this but is not working...Any suggestions?

Set sh = Sheets("IMPORTS")
n = Range("b65536").End(xlUp).Row

sh.Range("B4:E4" & n).Select

THANK YOU,
Navya
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
So you have to select B4 to E4, and B5 to E5, and B6 to E6, until you get to a Bx that is empty (or the last one, even if intermediate Bx's are empty)?

Or you have to select B4, C4, D4, E4, F4, ... until X4 is empty?

Or a combo of both?
 
Upvote 0
Navya,

If I understand the problem correct following procedure will do what You want:

<PRE>
<FONT color=blue>Sub </FONT>Selected_Range()

<FONT color=blue>Dim </FONT>wsSheet<FONT color=blue> As</FONT> Worksheet

<FONT color=blue>Dim </FONT>rnArea<FONT color=blue> As</FONT> Range



<FONT color=blue>Set </FONT>wsSheet = ThisWorkbook.Worksheets("Sheet1")



<FONT color=blue>With </FONT>wsSheet

<FONT color=blue>Set </FONT>rnArea = .Range(.Range("B4"), Range("E" & .Range("B65536").End(xlUp).Row))

<FONT color=blue>End With</FONT>



rnArea.Select



<FONT color=blue>End Sub</FONT>


</PRE>

HTH,
Dennis
 
Upvote 0

Forum statistics

Threads
1,224,247
Messages
6,177,409
Members
452,774
Latest member
Macca1962

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