An Quala
Board Regular
- Joined
- Mar 21, 2022
- Messages
- 146
- Office Version
- 2021
- Platform
- Windows
Hello, I use the following code to make a new file after deleting the certain columns from the old file, but I want to add one more thing here, if any of the three sheets ('Sponsored Products Campaigns', 'Sponsored Brands Campaigns' ,'Sponsored Display Campaigns') are empty (i.e. A2 is empty) then don´t import that sheet at all. Ideally don´t delete the columns as well since that is unnecessary in case of empty sheets but ultimately I don´t want those sheets in the new file.
Can anyone please help me do that?
Can anyone please help me do that?
VBA Code:
For Each x In Split("Sponsored Products Campaigns|Sponsored Brands Campaigns|Sponsored Display Campaigns", "|")
If Worksheets(x).UsedRange.Address <> "$A$1" Then
Campaigns " Select Case x"
Case "Sponsored Products Campaigns"
Worksheets(x).Range("F:G,J:Q,S:AA,AC:AU").EntireColumn.Delete
Case "Sponsored Brands"
Worksheets(x).Range("E:F,J:N,P:U,W:AY").EntireColumn.Delete
Case "Sponsored Display Campaigns"
Worksheets(x).Range("E:E,G:G,I:O,Q:Y,AA:AP").EntireColumn.Delete
End Select
End If
Next