SGTBARRETT
New Member
- Joined
- Apr 22, 2015
- Messages
- 2
I have written the following code to remove unwanted items from a sheet that is produced daily, elsewhere in my company. But for some reason, The first command selects the entire sheet and of course the delete command then deletes everything. I have a few columns that are at zero width, but I have even added script to set those to a width of 5 and it affects nothing. Everything still gets deleted.
If I run this on an empty sheet, it seems to work fine. Just not on the generated sheet. I'm gonna pull my hair out now...
-----------------------
Sub FormatCells()
'
' FormatCells Macro
'
'
Columns("G:G").Select
Range("G17").Activate
Selection.Delete Shift:=xlToLeft
Rows("1:9").Select
Range("A9").Activate
Selection.Delete Shift:=xlUp
Columns("M:Q").Select
Selection.Delete Shift:=xlToLeft
Columns("D:E").Select
Range("D17").Activate
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.ColumnWidth = 24.86
Columns("H:H").ColumnWidth = 55.86
Rows("2:60").Select
Selection.RowHeight = 24.75
End Sub
If I run this on an empty sheet, it seems to work fine. Just not on the generated sheet. I'm gonna pull my hair out now...

-----------------------
Sub FormatCells()
'
' FormatCells Macro
'
'
Columns("G:G").Select
Range("G17").Activate
Selection.Delete Shift:=xlToLeft
Rows("1:9").Select
Range("A9").Activate
Selection.Delete Shift:=xlUp
Columns("M:Q").Select
Selection.Delete Shift:=xlToLeft
Columns("D:E").Select
Range("D17").Activate
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.ColumnWidth = 24.86
Columns("H:H").ColumnWidth = 55.86
Rows("2:60").Select
Selection.RowHeight = 24.75
End Sub