+ Reply to Thread
Results 1 to 6 of 6

Macro for clearing cells in multiple ranges, Error 438

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    Lund, Sweden
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    15

    Macro for clearing cells in multiple ranges, Error 438

    Hey!

    Currently trying to create a macro for clearing multiple separate cell ranges.
    I got a macro of a website, added my cell ranges and tried to specify that it would run only on the active sheet. But running it gives "Run-time error '438'". It looks like this:

    Please Login or Register  to view this content.
    Any ideas what is wrong?
    Last edited by Christianekstrom; 11-01-2021 at 12:00 PM.

  2. #2
    Forum Expert WideBoyDixon's Avatar
    Join Date
    10-03-2016
    Location
    Sheffield, UK
    MS-Off Ver
    365
    Posts
    2,182

    Re: Macro for clearing cells in multiple ranges, Error 438

    Change this:

    Please Login or Register  to view this content.
    To either of these:

    Please Login or Register  to view this content.
    or

    Please Login or Register  to view this content.
    WBD
    Office 365 on Windows 11, looking for rep!

  3. #3
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: Macro for clearing cells in multiple ranges, Error 438

    This part doesn't make sense:

    Please Login or Register  to view this content.
    It's either:

    Please Login or Register  to view this content.
    to refer to the active sheet, or:

    Please Login or Register  to view this content.
    to refer to a sheet by name.
    Rory

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,481

    Re: Macro for clearing cells in multiple ranges, Error 438

    If you are setting the range for the active sheet, you don't need to say the workbook or sheet.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-29-2021
    Location
    Lund, Sweden
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    15

    Re: Macro for clearing cells in multiple ranges, Error 438

    Setting it to ".ActiveSheet ." gives the following msg: "Complie error: syntax error".
    Setting it to ".Sheets("Clear Cell") ." gives the same error msg.

    The app also highlights the line "Sub clearCellContentsKeepFormatting()" in yellow.

    I'm really new to VBA :/

  6. #6
    Registered User
    Join Date
    09-29-2021
    Location
    Lund, Sweden
    MS-Off Ver
    Microsoft 365 Apps for enterprise
    Posts
    15

    Re: Macro for clearing cells in multiple ranges, Error 438

    This worked, thanks alot!

+ 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. [SOLVED] Error at clearing cells
    By KingTamo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-21-2018, 04:21 PM
  2. [SOLVED] Macro Cell Clearing Error
    By stangz71 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-26-2015, 09:06 PM
  3. [SOLVED] run-time error 13 with code - Clearing Contents of cells
    By Chardo in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-18-2014, 03:23 AM
  4. [SOLVED] macro for clearing cells
    By superchew in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-29-2013, 10:40 PM
  5. [SOLVED] Clearing cells within an Array - Run-time error 13 (Type mismatch)
    By Wobbigone in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-21-2013, 01:37 AM
  6. [SOLVED] Clearing Ranges from Multiple workbooks.
    By Steve O in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-11-2005, 04:05 PM
  7. Clearing multiple cells in 1 click?
    By Lewis Koh in forum Excel Formulas & Functions
    Replies: 103
    Last Post: 09-06-2005, 07:05 PM

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