+ Reply to Thread
Results 1 to 9 of 9

Clear Contents below a dynamic Range

  1. #1
    Registered User
    Join Date
    11-24-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Clear Contents below a dynamic Range

    Hi everyone

    hopefully this is a simple one but my limited VBA experience has me stumped. I want to clear the contents of columns a and b when a is blank. Below is the table of sample data i want to clear cells a4:b7, however this range need to be dynamic based off if column A is blank and b contains something.
    a b
    1 1011111 500
    2 1011157 500
    3 1010257 500
    4 500
    5 500
    6 500
    7 500

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Clear Contents below a dynamic Range

    May be
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    11-24-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Clear Contents below a dynamic Range

    Unfortunately this did nothing!

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

    Re: Clear Contents below a dynamic Range

    Attach a before and after workbook. Pictures are notoriously difficult to try a code on.

  5. #5
    Registered User
    Join Date
    11-24-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Clear Contents below a dynamic Range

    BEFORE.JPGAFTER.JPG

    before and after atttached

  6. #6
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Clear Contents below a dynamic Range

    Try this:
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    11-24-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    5

    Re: Clear Contents below a dynamic Range

    Throws a runtime error '424' object required. do i need to set the used range?

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Clear Contents below a dynamic Range

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Valued Forum Contributor
    Join Date
    11-26-2012
    Location
    Sydney
    MS-Off Ver
    2010
    Posts
    419

    Re: Clear Contents below a dynamic Range

    No, UsedRange is built in. Maybe try adding 'sh' before the row and column count?
    Please Login or Register  to view this content.
    If that doesn't work, can you upload the spreadsheet?

+ 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] Extend Range To Clear Contents
    By Billy Spivy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-18-2018, 02:36 AM
  2. [SOLVED] Clear contents of range
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-25-2016, 01:15 PM
  3. [SOLVED] Clear contents for filtered range only
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-13-2016, 03:39 AM
  4. Clear contents in dynamic range
    By DCRAIG3389 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2015, 10:49 AM
  5. [SOLVED] If each cell in range equals 0 then clear contents of range and move to the next row
    By dagardner in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-19-2014, 08:44 PM
  6. [SOLVED] Clear Range Contents
    By kenadams378 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2013, 07:06 AM
  7. [SOLVED] clear contents of range
    By KATIEexcel in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-14-2012, 08:11 AM

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