+ Reply to Thread
Results 1 to 8 of 8

vba to clear contents in specific ranges on active sheet

  1. #1
    Forum Contributor
    Join Date
    11-12-2014
    Location
    Reading
    MS-Off Ver
    2016
    Posts
    100

    vba to clear contents in specific ranges on active sheet

    Not sure how to best word this.

    I've created a macro button that, adds a value of 1 to a specific cell every time it's pushed, it then exports (paste special) a specific range (A1:J50) in the active worksheet to a word doc and saves it as the name of another specified cell. My code is below:

    Please Login or Register  to view this content.

    Once all the above code has run, I'd like to clear the contents of specific ranges of cells but leave other cells alone. Those cells would be:

    B3:B4
    B14:B37
    C14:C31
    C33:C37
    H17:H37

    Everything else needs to be left alone.

    Any help so I can achieve that would be amazing.

    Also, I'll probably open a new thread once I've figured this out but if any of you reading this are skilled enough perhaps you can help me add in code that will save (not Save As) the Excel doc in it's original name and original location. No prompts required.

    Thanks in advance.

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba to clear contents in specific ranges on active sheet

    Add the below line before the end sub

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: vba to clear contents in specific ranges on active sheet

    Quote Originally Posted by blackburnsexcel View Post

    Also, I'll probably open a new thread once I've figured this out but if any of you reading this are skilled enough perhaps you can help me add in code that will save (not Save As) the Excel doc in it's original name and original location. No prompts required.

    Thanks in advance.
    add in this:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    11-12-2014
    Location
    Reading
    MS-Off Ver
    2016
    Posts
    100

    Re: vba to clear contents in specific ranges on active sheet

    Perfection thanks. Rep coming your way.

    Any ideas on saving as well?

    Thanks

  5. #5
    Forum Contributor
    Join Date
    11-12-2014
    Location
    Reading
    MS-Off Ver
    2016
    Posts
    100

    Re: vba to clear contents in specific ranges on active sheet

    Quote Originally Posted by Templemind View Post
    add in this:
    Please Login or Register  to view this content.
    Thanks, but I get runtime error '424'

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: vba to clear contents in specific ranges on active sheet

    Quote Originally Posted by blackburnsexcel View Post
    Thanks, but I get runtime error '424'
    Document refers to Word, if you want to save excel workbook then try this...

    ActiveWorkbook.Save

    Or

    Thisworkbook.save

  7. #7
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: vba to clear contents in specific ranges on active sheet

    Woops. I got confused.

  8. #8
    Forum Contributor
    Join Date
    11-12-2014
    Location
    Reading
    MS-Off Ver
    2016
    Posts
    100

    Re: vba to clear contents in specific ranges on active sheet

    Don't worry, you'll still get some rep. Thanks everyone. All solved.

    Here's the full code for anyone wanting to do the same.

    Please Login or Register  to view this content.

+ 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 contents of specific cells on the same row if a specific cell on that row is empty
    By djfscouse in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-28-2014, 01:48 PM
  2. macro to clear contents of two ranges if cell is blank
    By fisher-price in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-30-2011, 10:39 PM
  3. Clear sheet contents but retain Clipboard contents
    By nebb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2007, 01:42 PM
  4. How to set the position of a active cell and clear the contents of the cells
    By aijihz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-09-2007, 04:46 PM
  5. [SOLVED] Rename active sheet to contents of specific cell
    By burl_rfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2006, 07:40 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