Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Mike
 
Posts: n/a
Default count how many times a button is pressed

Hi i am using excel to print out cells from a form button using this macro
"ActiveSheet.Range("a8:b8").PrintOut preview:=False" 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
Paul B
 
Posts: n/a
Default count how many times a button is pressed

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("Sheet1").Range("A1").Value = _
Sheets("Sheet1").Range("A1").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 & 2003

"Mike" wrote in message
...
Hi i am using excel to print out cells from a form button using this macro
"ActiveSheet.Range("a8:b8").PrintOut preview:=False" 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



  #3   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default count how many times a button is pressed


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("a8:b8").PrintOut preview:=False
End Sub
______________________________

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=508788

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
count and limit radio button selections klintonselkirk Excel Worksheet Functions 1 August 17th 05 01:05 AM
limit and count radio button klintonselkirk Excel Discussion (Misc queries) 1 August 16th 05 11:41 PM
how do i count how many people are working between two times in e APYDS Excel Worksheet Functions 4 August 16th 05 08:11 PM
How do I count the # of times a value reoccurs and plot it over ti Stephen Charts and Charting in Excel 2 August 10th 05 10:32 PM
Whats the function to count the total times a word is displayed Monk Excel Discussion (Misc queries) 3 December 10th 04 10:39 PM


All times are GMT +1. The time now is 02:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"