help with macro please

G

Guest

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
 
D

davesexcel

Mike said:
:confused:
.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??!:mad:
 
P

Paul B

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top