+ Reply to Thread
Results 1 to 9 of 9

Clear data from multiple cells in multiple sheets.

  1. #1
    Registered User
    Join Date
    01-23-2020
    Location
    Colorado
    MS-Off Ver
    Office 365
    Posts
    4

    Clear data from multiple cells in multiple sheets.

    Hi,

    I want to create a "Clear All" button but I am having trouble with a macro to clear the same cell ranges from multiple sheets? Each sheet is named after each employee. Also, I don’t want to clear the first sheet called “Call History” and the cell range is F2:O3000. Can anyone help? Thank you for the help!

  2. #2
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Clear data from multiple cells in multiple sheets.

    If you had 5 worksheets named Call History, Bob, Carol, Ted, Alice, and you wanted to clear cell B3, C5, D7, and E9 in the last 4 in a single operation,

    Worksheets(Array("Bob", "Carol", "Ted", "Alice")).Range("B3,C5,D7,E9").ClearContents

  3. #3
    Registered User
    Join Date
    01-23-2020
    Location
    Colorado
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Clear data from multiple cells in multiple sheets.

    Thank you!

    This didn't clear the cell range.

  4. #4
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: Clear data from multiple cells in multiple sheets.

    Sorry. Working from evidently faulty memory and didn't test.

    Apparently this is one of the few things for which it's necessary to select objects.

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Clear data from multiple cells in multiple sheets.

    Or without selecting but with looping.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    01-23-2020
    Location
    Colorado
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Clear data from multiple cells in multiple sheets.

    Hi,

    Thank you hrlngrv and jolivanes! I used both but got the same error: Subscript out of range. Is there anything you see below that is incorrect?

    Sub Maybe_Without_Selecting()
    Dim wsArr, rngArr, i As Long
    wsArr = Array(“Pete LASTNAME”, “Austin”, “Enzo”, “Caroline”, “Riley”, “Carey”, “Cassady”, “Alyssa”, “Nate”, “Nathan”, “Emily”, “Marissa”, “Chuck”, “Meghan”, “Kyndra”, “Jessica”, “Libby”, “Hanani”, “Brian”, “Dean”, “Ashley”, “Stephanie”, “Alyssa”, “Alec ”, “Hava”, “Katie”, “John”, “Greg”, “Jared”, “Dee”)
    rngArr = Array(“F2:F5000”, “G2:G5000”, “H2:H5000”, “I2:I5000”, “J2:J5000”, “K2:K5000”, “L2:L5000”, “M2:M5000”, “N2:N5000”, “O2:O5000”)
    For i = LBound(wsArr) To UBound(wsArr)
    With Sheets(wsArr(i))
    .Range(rngArr(i)).ClearContents
    End With
    Next i
    End Sub

  7. #7
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Clear data from multiple cells in multiple sheets.

    You have a space in "Alec "
    That code needs an equal amount of entries in both arrays otherwise it fails. This one not
    Please Login or Register  to view this content.
    This would be a better approach by the looks of it.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-23-2020
    Location
    Colorado
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Clear data from multiple cells in multiple sheets.

    This worked, thank you for all you help!!!

  9. #9
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Clear data from multiple cells in multiple sheets.

    Thanks for letting us know and Good Luck

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro to clear data from multiple cells on multiple sheets
    By danielleissy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-26-2018, 08:37 AM
  2. [SOLVED] Clear cells on multiple sheets
    By Jazzmann in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-25-2015, 10:50 PM
  3. [SOLVED] How to Deselect Multiple Ranges on Multiple Sheets After Select & Clear
    By catnam in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 12-20-2014, 02:12 PM
  4. Loop and Clear Multiple Sheets
    By ptmuldoon in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2014, 08:26 PM
  5. Clear cell range on multiple sheets
    By Percheye in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-29-2012, 03:55 PM
  6. VBA to clear multiple ranges from list of sheets
    By y0rk1e72 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-07-2012, 10:12 AM
  7. Clear Multiple sheets
    By kithing in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-22-2010, 01:48 PM

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