using a command button from a macro

jkmclean

Board Regular
Joined
Jan 3, 2019
Messages
65
Office Version
  1. 365
Platform
  1. Windows
When I use a macro to open a userform and I click a command button on the form to load some data into the form, the code stops after the end sub of the command_click routine. It doesn't return to the original calling marco.

Public Sub CmdLoadTeams_Click()

Dim x As Long
Dim lane As Double
Dim tblroster As ListObject
Dim tbllanes As ListObject
Dim teamid As Double, team2id As Double
Worksheets("sheet1").Activate

Set tblroster = ActiveSheet.ListObjects("TeamRoster")
Worksheets("schedule").Activate

'For x = 2 To 36
Worksheets("sheet1").Activate
teamid = Sheet3.Range("m12") 'This is the row number
team2id = Sheet3.Range("m13")
id = Sheet3.Range("m10")
id2 = Sheet3.Range("m11")


On Error Resume Next
' Enter Players
ScoreSheet.T1P1 = tblroster.DataBodyRange(teamid, 4).Value
ScoreSheet.T1P1Hcp = tblroster.DataBodyRange(teamid, 3).Value
teamid = teamid + 1
ScoreSheet.T1P2 = tblroster.DataBodyRange(teamid, 4).Value
ScoreSheet.T1P2Hcp = tblroster.DataBodyRange(teamid, 3).Value
teamid = teamid + 1
ScoreSheet.T1P3 = tblroster.DataBodyRange(teamid, 4).Value
ScoreSheet.T1P3Hcp = tblroster.DataBodyRange(teamid, 3).Value
teamid = teamid + 1
ScoreSheet.T1P4 = tblroster.DataBodyRange(teamid, 4).Value
ScoreSheet.T1P4Hcp = tblroster.DataBodyRange(teamid, 3).Value

' Enter Players of opposing team

ScoreSheet.T2P1 = tblroster.DataBodyRange(team2id, 4).Value
ScoreSheet.T2P1Hcp = tblroster.DataBodyRange(team2id, 3).Value
team2id = team2id + 1
ScoreSheet.T2P2 = tblroster.DataBodyRange(team2id, 4).Value
ScoreSheet.T2P2Hcp = tblroster.DataBodyRange(team2id, 3).Value
team2id = team2id + 1
ScoreSheet.T2P3 = tblroster.DataBodyRange(team2id, 4).Value
ScoreSheet.T2P3Hcp = tblroster.DataBodyRange(team2id, 3).Value
team2id = team2id + 1
ScoreSheet.T2P4 = tblroster.DataBodyRange(team2id, 4).Value
ScoreSheet.T2P4Hcp = tblroster.DataBodyRange(team2id, 3).Value

MsgBox "PLEASE ENTER ALL THE SCORES FOR THESE TEAMS"

End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
.
Place a call back to the original macro at the end of the sub you have listed above.
 
Upvote 0

Forum statistics

Threads
1,215,488
Messages
6,125,092
Members
449,206
Latest member
ralemanygarcia

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