+ Reply to Thread
Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    08-07-2004
    Location
    Colorado
    MS-Off Ver
    2007
    Posts
    48

    Clear values, save formulas; Recalculate

    The attached sheet is used to inventory lottery tickets. The ticket number is scanned with a barcode reader and the info placed on an input line. Several other details are added then the line is "Added to inventory" with the macro button. The macro clears the input line so the next item can be entered. I can't clear the values without dumping the formulas in the calculating cells, which wouldn't be an issue but the cells won't recalculate the new input.

    I need to be able to clear the cell values (but leave the formulas) and need to kick the sheet to recalc the input row. Ideas?
    Attached Files Attached Files
    Last edited by itsunclebill; 03-21-2010 at 07:23 PM.

  2. #2
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: Clear values, save formulas; Recalculate

    Not sure what you mean, the code clears the cells,but leaves the formulas in the input line
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  3. #3
    Registered User
    Join Date
    08-07-2004
    Location
    Colorado
    MS-Off Ver
    2007
    Posts
    48

    Re: Clear values, save formulas; Recalculate

    The macro runs this
    Code:
    For Each cell In Range("rgnINV")
            If Not cell.HasFormula Then cell.ClearContents
        Next cell
    as part of the process. It's the only way I know to clear the cells with values in them. The code leaves formulas but also leaves the previously calc'd value. The line doesn't want to recalculate so I have to manually force the calculations to happen and don't understand why.

    Hit the "add to Inventory" key and see what happens

  4. #4
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: Clear values, save formulas; Recalculate

    Your example has Calculation set to Manual, see the Formulas Tab
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  5. #5
    Registered User
    Join Date
    08-07-2004
    Location
    Colorado
    MS-Off Ver
    2007
    Posts
    48

    Re: Clear values, save formulas; Recalculate

    Didn't know THAT was even in there. Thanks.

  6. #6
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: Clear values, save formulas; Recalculate

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

    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
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  7. #7
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: Clear values, save formulas; Recalculate

    This will be quicker than your loop for non formula cells
    Code:
        On Error Resume Next
        Range("rgnINV").SpecialCells(xlCellTypeConstants).ClearContents
        On Error GoTo 0
    Also,why the macro Sheet?
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

  8. #8
    Registered User
    Join Date
    08-07-2004
    Location
    Colorado
    MS-Off Ver
    2007
    Posts
    48

    Re: Clear values, save formulas; Recalculate

    Thanks for the clearcontents.

    Macro sheet is junk left over from another project and is just there and handy for the data valadation list. The project is VERY early alnog at this point and I haven't done my housecleaning yet.

  9. #9
    Forums Administrator royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    24,447

    Re: Clear values, save formulas; Recalculate

    Macro sheets are from Excel 95 I believe & totally unnecessary for later versions, use an ordinary worksheet
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel consulting, free examples and tutorials visit Excel Consulting-Excel VBA
    Check out the free Excel Toolbar

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)


    Code Tags: Make your code easier for us to read

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.2.0