Forum Discussion

A_SIRAT's avatar
A_SIRAT
Iron Contributor
Oct 18, 2023

Please help with a simple VBA Macro

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.

  • 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
  • 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

Resources