+ Reply to Thread
Results 1 to 9 of 9

I need a macro to erase all cells from B4:O402 with exception of a range of addresses?

  1. #1
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    I need a macro to erase all cells from B4:O402 with exception of a range of addresses?

    From B4:O402 i have a range of values, after putting an initial cell address in U1 and a last cell address in W1(this is a range of cells) , the macro must erase all the remaining cells.

    Such as:

    Initial Cell: U1=B19 Last Cell: W1=O35

    From B4:O402 all the cells must be erase with the only exception of range B19:O35

    I attached a worbook with an example.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    995

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    I assumed there are only values (no formula) in B4:O402.

    Do you want the remaining data move to the start (i.e B4) or stay in their position?

    This will move the remaining data move to the start:

    Please Login or Register  to view this content.
    This won't move the remaining data:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    Hi , Akuini the code worked.

    I just forget to mention that the data is in a sheet2

    Do you know how to reference "B4:O402" to sheet2?

    Thank you

  4. #4
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    995

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    Try this:

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    For some reason the code didnīt work, could it be that sheet 2 is with a space instead of sheet2 is actually sheet 2?

  6. #6
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    Hi akuini , I identified the problem

    U1 and W1 is in sheet 1

    and B4:BO402 is in sheet 2

    Its possible to refer U1 and W1 to sheet 1?

    Thanks again

  7. #7
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    995

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    Ok this one:

    Please Login or Register  to view this content.
    Edit:
    Sorry it should be:

    Please Login or Register  to view this content.
    Last edited by Akuini; 09-09-2019 at 10:01 PM.

  8. #8
    Forum Contributor
    Join Date
    07-09-2018
    Location
    Germany
    MS-Off Ver
    2016
    Posts
    257

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    Akuini , The code worked perfectly

    Thank you very much for your help.

  9. #9
    Valued Forum Contributor
    Join Date
    02-02-2016
    Location
    Indonesia
    MS-Off Ver
    Office 365
    Posts
    995

    Re: I need a macro to erase all cells from B4:O402 with exception of a range of addresses

    You're welcome, glad to help, & thanks for the feedback.

+ 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] Code to erase formula but keep text for specific cells in range
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-21-2018, 07:28 PM
  2. Vlookup Exception Or Macro to Deleting Cells
    By fahad_5214 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-03-2015, 09:13 PM
  3. Replies: 1
    Last Post: 02-03-2015, 09:10 PM
  4. Help: multi function macro needed - copy row, reset checkboxes, erase cells.
    By Acubed in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-29-2014, 09:37 AM
  5. Exception rule for highlighting cells macro
    By slavicgrip in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-07-2013, 01:33 AM
  6. Email a converted worksheet as pdf to addresses in a range of cells
    By Mosborne1 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-21-2011, 01:37 PM
  7. Get 1st and last addresses of cells in a range
    By SOS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-03-2008, 04:28 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