ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   help with macro please (https://www.excelbanter.com/excel-discussion-misc-queries/73989-help-macro-please.html)

Mike

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

davesexcel

help with macro please
 

Mike Wrote:


: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:


--
davesexcel
------------------------------------------------------------------------
davesexcel's Profile: http://www.excelforum.com/member.php...o&userid=31708
View this thread: http://www.excelforum.com/showthread...hreadid=516654


Paul B

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" wrote in message
...
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




Gary''s Student

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



All times are GMT +1. The time now is 12:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com