+ Reply to Thread
Results 1 to 9 of 9

Vba to clear values

  1. #1
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Vba to clear values

    Hi please could I have a VBA that will clear all values in Sheet 1 between D5:Q40 and Sheet 2 - between C5:R40.

    Many thanks

    Dave

  2. #2
    Forum Expert
    Join Date
    02-14-2009
    Location
    .
    MS-Off Ver
    ................
    Posts
    2,840

    Re: Vba to clear values

    Use the macro recorder while doing one range and see just how simple it is...

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,911

    Re: Vba to clear values

    Please Login or Register  to view this content.
    BSB

  4. #4
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Vba to clear values

    Quote Originally Posted by BadlySpelledBuoy View Post
    Please Login or Register  to view this content.
    BSB
    That's great. Would it be possible to add a "are you sure" to it to stop someone accidentally pressing clear?

  5. #5
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Vba to clear values

    Try this

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  6. #6
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Vba to clear values

    Hi many thanks, however it removes everything including the edges of the boxes and the back ground colour etc, is it possible to just clear the values and nothing else.

    Many thanks

  7. #7
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,911

    Re: Vba to clear values

    As Mike says in post #5 you can use .ClearContents rather than .Clear. This will only clear the values and leave the formatting etc.

    BSB

  8. #8
    Forum Contributor
    Join Date
    01-21-2017
    Location
    England
    MS-Off Ver
    2007
    Posts
    409

    Re: Vba to clear values

    Ah yea sorry thanks that works great

  9. #9
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,551

    Re: Vba to clear values

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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] How to clear two comboboxes that depend on each other values.
    By pietras152 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-09-2013, 08:32 PM
  2. Hyperlink to clear cell values
    By sahar in forum Excel General
    Replies: 0
    Last Post: 12-07-2011, 01:27 PM
  3. SOLVED: Clear Cells with Certain Values
    By tjohn909 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 03-28-2011, 01:11 PM
  4. Replies: 4
    Last Post: 04-01-2009, 06:15 PM
  5. Clear data but keep cell values
    By mrdata in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-21-2007, 04:49 AM
  6. clear all data values
    By punkiegirl420 in forum Excel General
    Replies: 3
    Last Post: 10-14-2006, 01:46 AM
  7. Macro to clear combo box values
    By Carpie in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2005, 02:05 PM
  8. Clear values
    By Rene' in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-04-2005, 01:06 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