select range from first cell with data thru last cell in col

richfm1

New Member
Joined
Aug 23, 2010
Messages
28
Hello,
i need the vba code to select the first cell with data in column a thru to the last cell with data same column.

thanks for your help
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try like this

Code:
Sub test()
Dim FR As Long, LR As Long
FR = Range("A1").End(xlDown).Row
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & FR & ":A" & LR).Select
End Sub
 
Upvote 0
If say it's in column A then:
Rich (BB code):
Sub SelectRange ()
Dim StartCell as Range, EndCell as Range
If Len(Range("A1")) > 0 Then
   Set StartCell = Range("A1")
Else
   Set StartCell = Range("A1").End(xlDown)
End If
Set EndCell = Range("A" & Rows.Count).End(Xlup)
If StartCell.Row = EndCell.Row Then StartCell.Select
If StartCell.Row > EndCell.Row Then 
   MsgBox "Valid range not available"
Else
   Range(StartCell, EndCell).Select
End If
End Sub
Change the red A's to whatever column you want this to work on
 
Upvote 0

Forum statistics

Threads
1,224,540
Messages
6,179,417
Members
452,912
Latest member
alicemil

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