Hi i am using excel to print out cells from a form button using this macro
quot;ActiveSheet.Range(quot;a8:b8quot;).PrintOut preview:=Falsequot; is there a way i can
modify it to count how many times the button is pressed and that amount shown
in an adjecent cell please
--
thanks
Mike, you could add a line of code to your macro like this, will add 1 to
sheet1 range A1 each time it is run
Sheets(quot;Sheet1quot;).Range(quot;A1quot;).Value = _
Sheets(quot;Sheet1quot;).Range(quot;A1quot;).Value 1--
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 amp; 2003
quot;Mikequot; gt; wrote in message
...
gt; Hi i am using excel to print out cells from a form button using this macro
gt; quot;ActiveSheet.Range(quot;a8:b8quot;).PrintOut preview:=Falsequot; is there a way i
can
gt; modify it to count how many times the button is pressed and that amount
shown
gt; in an adjecent cell please
gt; --
gt; thanks
Hello Mike,
Add this code to a VBA module in your workbook. It will place the
number of times the button has been pushed in the cell to the right of
the button and then call the print function.
______________________________
Public Sub ButtonCount()
Dim Col As Long
Dim Row As Long
With ActiveSheet.Shapes(Application.Caller)
Row = .TopLeftCell.Row
Col = .BottomRightCell.Column
End With
With Cells(Row, Col)
.Value = .Value 1
End With
ActiveSheet.Range(quot;a8:b8quot;).PrintOut preview:=False
End Sub
______________________________
Sincerely,
Leith Ross--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: www.excelforum.com/member.php...oamp;userid=18465
View this thread: www.excelforum.com/showthread...hreadid=508788
- Apr 21 Sat 2007 20:36
count how many times a button is pressed
close
全站熱搜
留言列表
發表留言