Announcement

Collapse
No announcement yet.

VBA to Clear Contents of Every Alternate Cell in a Column

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBA to Clear Contents of Every Alternate Cell in a Column

    I need to clear the contents of every alternate cell in a column, starting at cell C10, then C12 . . . . all the way down the column. I've searched for guidance but everything I've found to date relates to deleting entire rows or entire columns.

    Help with VBA coding to achieve this will be much appreciated.

  • #2
    Re: VBA to Clear Contents of Every Alternate Cell in a Column

    Try this
    Code:
    Sub ClearAlternateCells()
        Dim x, i As Long, lRow As Long
        
        With ActiveSheet
            lRow = .Cells(.Rows.Count, 3).End(xlUp).Row
            With .Range("c10:c" & lRow)
                x = .Value
                For i = 1 To UBound(x, 1) Step 2
                    x(i, 1) = vbNullString
                Next
                .Value = x
            End With
        End With
        
    End Sub
    We now have a reputation system in place. It can be found on the 'Star' icon on the bottom left hand side of the post

    Comment


    • #3
      Re: VBA to Clear Contents of Every Alternate Cell in a Column

      Perfect! Does exactly what I needed.

      Thank you very much for your prompt and effective response.

      Comment


      • #4
        Re: VBA to Clear Contents of Every Alternate Cell in a Column

        You're welcome.
        We now have a reputation system in place. It can be found on the 'Star' icon on the bottom left hand side of the post

        Comment

        Working...
        X