+ Reply to Thread
Results 1 to 4 of 4

Clear the contents on for rows 4 through 500 on every fourth column starting with column E

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2013
    Location
    Illinois
    MS-Off Ver
    Excel 2010
    Posts
    1

    Clear the contents on for rows 4 through 500 on every fourth column starting with column E

    Looking for a quick way using VBA to clear the contents of rows 7-500 for every fourth column from column E to column JY.

    E7:E500
    I7:I500
    M7:M500
    {continues...}
    JY7:JY500


    I could manually enter column in VBA, such as

    Sub ClearAllRunningTimes()
    '
    ' ClearAllRunningTimes Macro
    '
    Range("E7:E500").Select
    Selection.ClearContents

    Range("I7:I500").Select
    Selection.ClearContents

    Range("M7:M500").Select
    Selection.ClearContents

    etc...

    End Sub

    But there has to be an easier way. Thanks!
    Brian

  2. #2
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Re: Clear the contents on for rows 4 through 500 on every fourth column starting with colu

    Try this:

    Sub Macro3()
    
    Dim ColNum As Long
        
    For ColNum = 1 To 281
        If ((ColNum + 4) Mod 4) = 0 Then
            Range(Cells(7, ColNum + 4), Cells(500, ColNum + 4)).ClearContents
        End If
    Next ColNum
    
    End Sub

  3. #3
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Re: Clear the contents on for rows 4 through 500 on every fourth column starting with colu

    Wait, I just realized you started by clearing Col E first. Let me revise this.

  4. #4
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Atlanta
    MS-Off Ver
    Excel 2007
    Posts
    171

    Re: Clear the contents on for rows 4 through 500 on every fourth column starting with colu

    Actually, its a simple change. Just replace:

    If ((ColNum + 4) Mod 4) = 0

    with

    If ((ColNum + 4) Mod 4) = 1

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1