Microsoft Office Forums How to run two button macros with one button?

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2013, 07:47 AM
Geza59 Geza59 is offline How to run two button macros with one button? Windows XP How to run two button macros with one button? Office 2003
Novice
How to run two button macros with one button?
 
Join Date: May 2012
Location: Budapest, Hungary
Posts: 20
Geza59 is on a distinguished road
Question 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
Reply With Quote
  #2  
Old 02-14-2013, 12:11 AM
macropod's Avatar
macropod macropod is offline How to run two button macros with one button? Windows 7 64bit How to run two button macros with one button? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,525
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

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
[MS MVP - Word]
Reply With Quote
Reply

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
How to run two button macros with one button? 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


All times are GMT -7. The time now is 12:19 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2019 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft