+ Reply to Thread
Results 1 to 7 of 7

Adapt code to clear content in range

  1. #1
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    74

    Adapt code to clear content in range

    Hi all,

    I have a line of code Im using to clear a sheet after calculations have been performed. Right now it removes the entire row starting at row 2:

    Sheets("OPERATIONS").Rows(2 & ":" & Sheets("OPERATIONS").Rows.Count).ClearContents

    Is it possible to change this line to only perform this action from column A to H? Column G includes formulas I'd like to keep. So it should clear only A2:H<max row count in>

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    32,350

    Re: Adapt code to clear content in range

    You do know that G comes before H, don't you?

    Regards, TMS
    Trevor Shuttleworth - Excel Aid

    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


  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    32,350

    Re: Adapt code to clear content in range

    Please Login or Register  to view this content.

    Regards, TMS

  4. #4
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    74

    Re: Adapt code to clear content in range

    I am quite familiar with the alphabet. I was tired and wanted to go to bed so I rushed the post

    Unfortunately the code you provided removed the first row as well.

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    32,350

    Re: Adapt code to clear content in range

    Sorry, it was late and I was tired ... didn't read the requirement properly

    Just remove the .EntireColumn


    Regards, TMS

  6. #6
    Registered User
    Join Date
    03-26-2015
    Location
    Netherlands
    MS-Off Ver
    2013
    Posts
    74

    Re: Adapt code to clear content in range

    Thx! That did the trick.

  7. #7
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    32,350

    Re: Adapt code to clear content in range

    You're welcome. Thanks for the rep.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] Clear content referencing another cell's same content
    By papusale in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-08-2015, 05:21 AM
  2. Clear Content of conditional dynamic range
    By georgeofthejungle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2014, 12:20 PM
  3. [SOLVED] clear dynamic named range content
    By intex in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-12-2014, 08:29 AM
  4. [SOLVED] Clear Content if cell in a range contain #N/A VBA
    By alex_shin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-16-2014, 06:33 PM
  5. [SOLVED] How to adapt a code to include a range of cells instead of the whole sheet
    By nje in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-08-2013, 08:52 AM
  6. [SOLVED] Adapt VBA code to clear the related cells instead of update
    By michelle 1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-26-2013, 05:50 AM
  7. [SOLVED] Clear content if ... Multiple VB Code (Excel 2003)
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2012, 02:35 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