Delete Rows and Sheets

S

Sal

Is there a better way to delete row 1 in Sheet1 than this

Sheets("Sheet1").Select
Rows("1:1").Select
Selection.Delete Shift:=xlUp
Range("A1").Select

Is there a better way to delete Column B in Sheet1 than this?

Sheets("Sheet1").Select
Columns("B:B").Select
Selection.Delete Shift:=xlToLeft

Is there a better way using Sheet1, to Cut Column D and paste the cut cells
in front of Column A than this?
Sheets("Sheet1").Select
Columns("D:D").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
 
J

Jacob Skaria

When you record a macro ;each single action is recorded....the below code
does the same 3 actions///

Sheets("Sheet1").Rows(1).Delete
Sheets("Sheet1").Columns(1).Delete
Columns("A:A").Insert Shift:=xlToRight



If this post helps click Yes
 
J

Jacob Skaria

You can avoid the Workbook and sheetname..

With ActiveWorkbook.Sheets("Sheet1")
..Rows(1).Delete
..Columns(1).Delete
..Columns("D:D").Cut
..Columns("A:A").Insert Shift:=xlToRight
End With

If this post helps click Yes
 
S

Sal

Perfect! Thank you

Jacob Skaria said:
When you record a macro ;each single action is recorded....the below code
does the same 3 actions///

Sheets("Sheet1").Rows(1).Delete
Sheets("Sheet1").Columns(1).Delete
Columns("A:A").Insert Shift:=xlToRight



If this post helps click Yes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top