Hey guys,
So this is my first VBA project I've ever done. But what I need is to go through about 50 worksheets and delete partially blank columns and shift the full columns to the left.
I pull this data from PDF files and it is causing this formatting error. However, it also sometimes pulls in arrows (">"), which makes deleting the columns based on if they're empty difficult. Also the cells these arrows are in change, as do which columns are empty.
I would like this file to go through each worksheet(starting at the 5th worksheet (the first 4 are all formatted correctly). And then delete the empty columns (including columns that are empty except for ">"s)
This is the code I've written so far. It works so far but it won't go through each worksheet.
Sub CycleWorkSheets()
Dim mySheet As Worksheet
Dim i As Long
For i = 5 To ThisWorkbook.Worksheets.Count
Set mySheet = ThisWorkbook.Worksheets(i)
DeleteEmptyShiftLeft
Next i
End Sub
Private Sub DeleteEmptyShiftLeft()
Dim rngMyCell As Range
DeleteArrows
For Each rngMyCell In Range("C1:P700")
If (rngMyCell.Value) = "" And (rngMyCell.Column > 2) Then
rngMyCell.Delete Shift:=xlToLeft
End If
Next rngMyCell
Format
End Sub
Private Sub DeleteArrows()
Dim mySheet As Worksheet
For Each Cell In [A1:S700]
If Cell.Value() = ">" Then Cell.ClearContents
Next Cell
End Sub
Thanks in advance for any help
So this is my first VBA project I've ever done. But what I need is to go through about 50 worksheets and delete partially blank columns and shift the full columns to the left.
I pull this data from PDF files and it is causing this formatting error. However, it also sometimes pulls in arrows (">"), which makes deleting the columns based on if they're empty difficult. Also the cells these arrows are in change, as do which columns are empty.
I would like this file to go through each worksheet(starting at the 5th worksheet (the first 4 are all formatted correctly). And then delete the empty columns (including columns that are empty except for ">"s)
This is the code I've written so far. It works so far but it won't go through each worksheet.
Sub CycleWorkSheets()
Dim mySheet As Worksheet
Dim i As Long
For i = 5 To ThisWorkbook.Worksheets.Count
Set mySheet = ThisWorkbook.Worksheets(i)
DeleteEmptyShiftLeft
Next i
End Sub
Private Sub DeleteEmptyShiftLeft()
Dim rngMyCell As Range
DeleteArrows
For Each rngMyCell In Range("C1:P700")
If (rngMyCell.Value) = "" And (rngMyCell.Column > 2) Then
rngMyCell.Delete Shift:=xlToLeft
End If
Next rngMyCell
Format
End Sub
Private Sub DeleteArrows()
Dim mySheet As Worksheet
For Each Cell In [A1:S700]
If Cell.Value() = ">" Then Cell.ClearContents
Next Cell
End Sub
Thanks in advance for any help