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!

Deleting Rows Above & Columns To Left Of A Specific Cell

Status
Not open for further replies.

tobyjuggler

Technical User
Sep 13, 2001
4
GB
I'm trying to write a macro that will delete all of the rows above and all of the columns to the left of a selected cell (the cell might be a difeerent one each time the macro is run) - the aim being that that active cell ends up being in the A1 position. Does anybody have any idea how this is done? Any help would be much appreciated.
 
This will do it.

Private Sub DeleteRowsAndColumns()
ActiveSheet.Rows("1:" & ActiveCell.Row - 1).Delete

For i = ActiveCell.Column - 1 To 1 Step -1
ActiveSheet.Columns(i).Delete
Next i
End Sub

You might like to find a quickier way to delete the columns.
 
Thanks a lot DarkSun, you are a star! (forgive the pun, please). It works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top