+ Reply to Thread
Results 1 to 8 of 8

Reset Button

Hybrid View

  1. #1
    Registered User
    Join Date
    05-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Reset Button

    Hi, I have a column of 36 cells that users can enter percentages into (whatever percentage they want), after they are done, I would like to just have a reset button that will return all cell values to zero.

    I put an ActiveX command button on the page, I just don't know the right VBA syntax to use in the button's Private Sub.

    If someone could help me out that would be great! Thank you!

  2. #2
    Registered User
    Join Date
    04-20-2012
    Location
    New York, NY
    MS-Off Ver
    Excel 2013, 2010, 2007, 2003
    Posts
    99

    Re: Reset Button

    Try this,

    Sub Reset()
    
        Range("A1").Select
        ActiveCell.FormulaR1C1 = "0"
        Selection.AutoFill Destination:=Range("A1:A36"), Type:=xlFillDefault
        'Modify above for your range of 36 cells
        
    End Sub
    Modify for your range of cells as noted.
    SPARTAN
    Please click the * if my solution helped

  3. #3
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Reset Button

    Use this and replace the A with the column name

    Range("A1:A36") = 0
    Regards,
    Khaled Elshaer
    www.BIMcentre.com

    Remember To Do the Following....
    1. Thank those who have helped you by clicking the Star below their post.
    2. Mark your post SOLVED if it has been answered satisfactorily:
    • Select Thread Tools (on top of your 1st post)
    • Select Mark this thread as Solved

  4. #4
    Registered User
    Join Date
    05-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Reset Button

    Thanks singerj6 - that pretty much works, is there a way to right the autofill part so that it only copies the values though? There is a border above my first value so right now its copying that down. Thanks!

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Reset Button

    I would use a Forms button, they are more reliable and assign the macro to it.

    You con't need to select any cells either

    Option Explicit
    
    Sub Reset()
    Range(Cells(1, 1), Cells(36, 1)).Value = 0
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    Registered User
    Join Date
    05-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Reset Button

    Roy - that seems like maybe a simpler way to do it. I tried doing what you had said but it doesn't seem to be working though. Where should I be entering that code? Just create a new macro in that worksheet or what?

    Thanks!

  7. #7
    Valued Forum Contributor
    Join Date
    08-29-2011
    Location
    Mississauga, CANADA
    MS-Off Ver
    Excel 2010
    Posts
    503

    Re: Reset Button

    @BJbeans
    Did u try my code?

  8. #8
    Registered User
    Join Date
    05-03-2012
    Location
    NYC
    MS-Off Ver
    Excel 2007
    Posts
    19

    Re: Reset Button

    Roy - I ended up using your code and it works well, now I have an added tweak though that I'm trying to figure out.

    Instead of tying the macro to a button, I'd like to just key it off of a cell in the worksheet. I've enabled the cell at the top of my column for data validation to be a list, lets call it cell B1. I'd like to make the list 2 options, "Column Name", and "Reset". When you toggle to "Reset" I'd like that to run the macro.

    I've tried to write an If function in VBA around your code - If Range(Cells(1,2)).Value = "Reset" Then...run your code, but this doesn't seem to be working. Any advice?

    Thanks!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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