+ Reply to Thread
Results 1 to 6 of 6

Add a clear values code to command button

  1. #1
    Registered User
    Join Date
    08-23-2010
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Add a clear values code to command button

    I am using a command button to autopopulate one worksheet (named ranges) with values from another worksheet. (thanks to this forums help!).

    One slight problem. When i change the values in column b on "invoicing" worksheet, which designates which column in "cashflow" worksheet to put the data in, i am left with duplicate values. Data input into the originaly populated column and also the new data.

    All i need is a code to add to the command button that will clear all values in worksheet "cashflow", columns C:? first, then run the code required to populate and new information.

    For more information, please see my post http://www.excelforum.com/excel-prog...-criteria.html

    Please see sample file attached, and note that i have indicated particular ranges on the code that do not show on this attachment, as it is only a sampling of my file.
    Attached Files Attached Files
    Last edited by titantough; 06-14-2011 at 12:02 AM.

  2. #2
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Add a clear values code to command button

    Hi titan, does the Weeks to pay have to be cleared too?
    If you're happy with someone's help, click that little star at the bottom left of their post to give them Reps.

    ---Keep on Coding in the Free World---

  3. #3
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Add a clear values code to command button

    Just add the following code to your button_click sub:
    Please Login or Register  to view this content.
    Add right after your Dim declarations and it will be the first thing the sub does.

  4. #4
    Registered User
    Join Date
    08-23-2010
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Add a clear values code to command button

    Hi Mordred,

    Thanks very much. Could you please advise how i would expand the clearing range, but to specified cells and rows?

    I am wanting to clear "cashflow" worksheet columns C:W, rows 6:9 in this sample file. (My original file is columns C:AV and rows 6:27 and rows 31:40).

    Thanks,
    Last edited by titantough; 06-13-2011 at 11:56 PM.

  5. #5
    Registered User
    Join Date
    08-23-2010
    Location
    Alberta, Canada
    MS-Off Ver
    Excel 2007
    Posts
    30

    Re: Add a clear values code to command button

    Oh for Pete's sake!
    It is just a matter of changing my range!

    Please Login or Register  to view this content.
    Thanks again Mordred, hope you have a great evening.

  6. #6
    Forum Expert Mordred's Avatar
    Join Date
    07-06-2010
    Location
    Winnipeg, Canada
    MS-Off Ver
    2007, 2010
    Posts
    2,787

    Re: Add a clear values code to command button

    I am hoping that you read this once more because clearing your range is very permanent. As far as I know, there is no recovering from that unless you close without saving. Not that I am trying to be nosy but is your data being logged somewhere else, or does it even need to be? Also, is the range that you used in post # 5 a fixed permanent range the will never increase? If it is not fixed we can change the code a bit to allow for a change in the range.

    More importantly and to reiterate, be sure that the data you clear is 100% "OK" for clearing.

    Regards:

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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