Calling a sub from userform - control button

SeniorTom

Board Regular
Joined
Jun 5, 2017
Messages
96
I have code that I have tested and now want to add a user form with a cancel and OK button to run or cancel it. I have looked at various answers to call the sub, but I can’t get it to work. I have made all the sub being called "Public". Any help would be appreciated.

Regards,
Tom

The following is in "responses.xlsm - sheet1 (code) (General) - update tracking"

Public Sub update_trackingFile()
' Routing to take responses from a google form's spreadsheet. It will also email a response to
' the requester's email

' makes sure the Roster file is open
mylocalpath = ThisWorkbook.Path
MyActivefile = ThisWorkbook.FullName
With MyActivefile
' confirm that the roster file is open and the version you want
Call OfferRosterFile

' Insert the email address in the response file
Call insertEmail
.
.
.
Public Sub showDialogBox()
UpdateForm.Show

End Sub


The following is in "responses.xlsm – updateform (code) UserForm – click"

Public Sub CancelButton_Click()
Unload UpdateForm
End Sub

Public Sub OKButton_Click()

ThisWorkbook.Activate
With ThisWorkbook
Call update_trackingFile ‘ get sub or function not defined.
End With
End Sub
Public Sub UserForm_Click()

End SubI have code that I have tested and now want to add a user form with a cancel and OK button to run or cancel it. I have looked at various answers to call the sub, but I can’t get it to work.

The following is in responses.xlsm - sheet1 (code) (General) - update tracking
Public Sub update_trackingFile()
' Routing to take responses from a google form's spreadsheet. It will also email a response to
' the requester's email

' makes sure the Roster file is open
mylocalpath = ThisWorkbook.Path
MyActivefile = ThisWorkbook.FullName
With MyActivefile
' confirm that the roster file is open and the version you want
Call OfferRosterFile

' Insert the email address in the response file
Call insertEmail
.
.
.
Public Sub showDialogBox()
UpdateForm.Show

End Sub


The following is in responses.xlsm – updateform (code) UserForm – click

Public Sub CancelButton_Click()
Unload UpdateForm
End Sub

Public Sub OKButton_Click()

ThisWorkbook.Activate
With ThisWorkbook
Call update_trackingFile ‘ get sub or function not defined.
End With
End Sub
Public Sub UserForm_Click()

End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Code:
[COLOR=#333333]Call [/COLOR][COLOR=#333333][B]sheet1.[/B][/COLOR][COLOR=#333333]update_trackingFile[/COLOR]
 
Upvote 0

Forum statistics

Threads
1,216,074
Messages
6,128,653
Members
449,462
Latest member
Chislobog

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top