+ Reply to Thread
Results 1 to 5 of 5

VBA to clear dynamic range based on cell value

  1. #1
    Registered User
    Join Date
    10-11-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    17

    VBA to clear dynamic range based on cell value

    Hello,

    I have this line of code that isn't working


    Range("AV" & Sheets("Setup").Range("AT1").Value & ":AV50000").Clear


    What I need: Cell AT1 has a number in it, I need to clear everything for the cells in row AV starting in the number in AT1 through row 50000.

    I tried a couple different variations and Im just not getting it. This is my last attempt, I know it was a long shot but I ran out of ideas.

    Grant

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

    Re: VBA to clear dynamic range based on cell value

    You could be missing other details, but here is my interpretation. Besides the variables, the codes look exactly the same, if it doesn't work, you may have to supply a sample.

    Please Login or Register  to view this content.

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

    Re: VBA to clear dynamic range based on cell value

    As for me it's working
    Please Login or Register  to view this content.
    When running the code ..What's the active sheet that you worked on?
    Have you got more that one sheet?
    I tried this line in "Sheet1" .. But the value in AT1 was put in "Setup" sheet

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,422

    Re: VBA to clear dynamic range based on cell value

    There's nothing wrong with the code; it works fine.

    What's in cell AT1 on the Setup worksheet? Is it a positive number? What sheet is selected? Is the sheet protected? What happens? Do you get an error message? If yes, what is it? If no, does it just do nothing? Or does it clear somewhere else?

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Registered User
    Join Date
    10-11-2013
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: VBA to clear dynamic range based on cell value

    I got it to work.....sort of

    I came up with this idea as a fix for my main problem here

    http://www.excelforum.com/excel-prog...ml#post4009054

    but I am still getting the blank cells inbetween entries

+ 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. Clear Content of conditional dynamic range
    By georgeofthejungle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2014, 12:20 PM
  2. [SOLVED] clear dynamic named range content
    By intex in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-12-2014, 08:29 AM
  3. Dynamic Range for clear cells on change
    By Snickers65 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-29-2013, 06:28 PM
  4. Clear range based on cell value - clearing cells out of specified range
    By CADiphile in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-15-2013, 02:48 PM
  5. Replies: 1
    Last Post: 06-21-2013, 04:05 AM

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