#1
|
|||
|
|||
How to run two button macros with one button?
Hi again!
I have a macro "CommandButton2_Click" assigned to a button a Sheet1 that can output the current date and time to a text file. Another button on Sheet2 ("CommandButton4_Click") outputs the required data to the same text file. So, how can I modify the 2nd macro, so that it will also export the date and time before exporting the required data to the text file? I tried to use "Call" with the 2nd macro like this: Code:
Private Sub CommandButton4_Click() Call Sheet1.CommandButton2_Click Dim FileName As String ' the file to write to Dim DataRange As Range ' the range containing the data to export Dim Append As Boolean ' whether to append or overwrite existing data etc. End If End Sub |
#2
|
||||
|
||||
I'd put the code used by CommandButton2 into a separate sub, probably in a general code module, and have both CommandButtons reference that sub. The alternative is to have the same piece of code attached to both CommandButtons.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Deleting Macro Button | mata30s | Word VBA | 0 | 01-23-2013 12:04 PM |
Command Button | cksm4 | Word VBA | 7 | 02-27-2011 08:47 PM |
Macro Button | B2W | Excel | 2 | 06-18-2010 09:36 AM |
calling images with a button | sammer021486 | PowerPoint | 0 | 01-13-2010 08:24 AM |
Help on option button active X | aligahk06 | Excel | 0 | 11-03-2009 11:39 PM |