Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Seting a range to where there only data

Status
Not open for further replies.

balistikb

Technical User
Nov 12, 2002
177
US
I am trying to modify a macro with VB and I need to be able to select a range where ther is only data. What I have now is this Range("A2:H9").Select. I know this just selects what I have put as a range. How to I just select a range where there is data only. The range may grow or shrink depending on how much information I have in my sheet.
 
Try

x = Cells.SpecialCells(xlCellTypeLastCell).Row
y = Cells.SpecialCells(xlCellTypeLastCell).Column

Range(Cells(1, 1), Cells(x, y)).Select
 
Do I actualy type (xlCellTypeLastCell) or am I supposed to enter something in there?
 
If you just copy what I have but you will get a selection from A1 to the last cell you have used.
 
This did work thanks.
Now I am trying to figure out how to group and then select that range. All in VB behind excel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top