+ Reply to Thread
Results 1 to 4 of 4

help with macro please

  1. #1
    Mike
    Guest

    help with macro please

    I'm using the macro below Kindly sent to me by Bob Phillips, to print out
    when in press a button in excel, It works great except it resets to zero
    before it prints is there a way to get it to print the value in AA2 before it
    resets it back to zero

    Sub Button2_Click()
    With Sheets("Sheet1")
    .Range("AB3").Value = _
    .Range("AB3").Value + .Range("AA2").Value
    .Range("AA2").Value = 0
    End With
    ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    End Sub

    Thanks

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    Quote Originally Posted by Mike


    .Range("AA2").Value = 0
    End With
    ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    End Sub

    Thanks
    Look at the code, do you see it sets to Zero before it prints, can you think of a way to stop setting it to zero before the print command??!

  3. #3
    Paul B
    Guest

    Re: help with macro please

    Mike, try this,

    Sub Button2_Click()
    With Sheets("Sheet1")
    .Range("AB3").Value = _
    .Range("AB3").Value + .Range("AA2").Value
    ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    .Range("AA2").Value = 0
    End With

    End Sub


    --
    Paul B
    Always backup your data before trying something new
    Please post any response to the newsgroups so others can benefit from it
    Feedback on answers is always appreciated!
    Using Excel 2002 & 2003

    "Mike" <[email protected]> wrote in message
    news:[email protected]...
    > I'm using the macro below Kindly sent to me by Bob Phillips, to print out
    > when in press a button in excel, It works great except it resets to zero
    > before it prints is there a way to get it to print the value in AA2 before

    it
    > resets it back to zero
    >
    > Sub Button2_Click()
    > With Sheets("Sheet1")
    > .Range("AB3").Value = _
    > .Range("AB3").Value + .Range("AA2").Value
    > .Range("AA2").Value = 0
    > End With
    > ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    > End Sub
    >
    > Thanks




  4. #4
    Gary''s Student
    Guest

    RE: help with macro please

    Try to move the reset to zero after the print:



    Sub Button2_Click()
    With Sheets("Sheet1")
    .Range("AB3").Value = _
    .Range("AB3").Value + .Range("AA2").Value
    End With
    ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    Sheets("Sheet1").Range("AA2").Value = 0
    End Sub
    --
    Gary''s Student


    "Mike" wrote:

    > I'm using the macro below Kindly sent to me by Bob Phillips, to print out
    > when in press a button in excel, It works great except it resets to zero
    > before it prints is there a way to get it to print the value in AA2 before it
    > resets it back to zero
    >
    > Sub Button2_Click()
    > With Sheets("Sheet1")
    > .Range("AB3").Value = _
    > .Range("AB3").Value + .Range("AA2").Value
    > .Range("AA2").Value = 0
    > End With
    > ActiveSheet.Range("AG3:AH10").PrintOut preview:=False
    > End Sub
    >
    > Thanks


+ 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