SOLVED

Please help with a simple VBA Macro

Iron Contributor

Hi,

 

I have a file that I would like to have a macro that will clear the contents of cells E18:F19 on all the sheets except the first sheet named " Action". I have sampled two sheets but they could be more than that.

These two cells are sent with data that is not compatible with my other program and I have to manually clear the cells. The file has two macros running perfectly doing other things.

thanks in advance.

2 Replies
best response confirmed by A_SIRAT (Iron Contributor)
Solution

@A_SIRAT 

Like this:

Sub ClearData()
    Dim wsh As Worksheet
    Application.ScreenUpdating = False
    For Each wsh In Worksheets
        Select Case wsh.Name
            Case "Action"
                ' Skip sheet
            Case Else
                wsh.Range("E18:F19").ClearContents
        End Select
    Next wsh
    Application.ScreenUpdating = True
End Sub
Thank you!
1 best response

Accepted Solutions
best response confirmed by A_SIRAT (Iron Contributor)
Solution

@A_SIRAT 

Like this:

Sub ClearData()
    Dim wsh As Worksheet
    Application.ScreenUpdating = False
    For Each wsh In Worksheets
        Select Case wsh.Name
            Case "Action"
                ' Skip sheet
            Case Else
                wsh.Range("E18:F19").ClearContents
        End Select
    Next wsh
    Application.ScreenUpdating = True
End Sub

View solution in original post