ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate a moacro subroutine from a userform command button (https://www.excelbanter.com/excel-programming/436731-activate-moacro-subroutine-userform-command-button.html)

Roger on Excel

Activate a moacro subroutine from a userform command button
 
[Excel 2003]

I use macros in a worksheet - for example:

Sub DateStamp()
Range("b14") = Date & " " & Time 'Date And Time
End Sub

I access the macro with a command button in the spreadsheet.

I would now like to access the same code using a command button on a Userform.

I guess I could repeat the same code in the command button on the userform,
but I would rather not duplicate the code.

Is there a way to do this?

Many thanks,

Roger

Mike H

Activate a moacro subroutine from a userform command button
 
Hi,

Private Sub CommandButton1_Click()
Call DateStamp
End Sub

Mike

"Roger on Excel" wrote:

[Excel 2003]

I use macros in a worksheet - for example:

Sub DateStamp()
Range("b14") = Date & " " & Time 'Date And Time
End Sub

I access the macro with a command button in the spreadsheet.

I would now like to access the same code using a command button on a Userform.

I guess I could repeat the same code in the command button on the userform,
but I would rather not duplicate the code.

Is there a way to do this?

Many thanks,

Roger



All times are GMT +1. The time now is 10:18 AM.

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