Hello
I have an issue with a macro running till the end instead of waiting for a called userform input. Below is the the code and the called userform code. As you see the SamOpt2x macro finds a cell containing "Sample #1 " and selects the cell. At that point the userform macro is called and will use the activecell value to produce a userform label. The label would be "Sample #1 Info". The userform also contains textboxes for the sample info. The userform has a command button that when clicked puts the information in desired cells. Trouble is, the macro runs all the way through and the userform label is "Sample #2 Info". Is there a way to prompt the macro to wait for the SamInf userform command button click?
I have an issue with a macro running till the end instead of waiting for a called userform input. Below is the the code and the called userform code. As you see the SamOpt2x macro finds a cell containing "Sample #1 " and selects the cell. At that point the userform macro is called and will use the activecell value to produce a userform label. The label would be "Sample #1 Info". The userform also contains textboxes for the sample info. The userform has a command button that when clicked puts the information in desired cells. Trouble is, the macro runs all the way through and the userform label is "Sample #2 Info". Is there a way to prompt the macro to wait for the SamInf userform command button click?
Code:
Sub Click_SamOpt2x()
Columns("B:B").Find("Sample #1").Select
Call Show_SamInf
Columns("B:B").Find("Sample #2").Select
Call Show_SamInf
End Sub
Code:
Sub Show_SamInf()
SamInf.Show
With SamInf
.Height = 210
.Width = 420
.Caption = "Show_SamInf"
With SamInf.SamInfLabel
.Top = 10
.Width = 400
.Height = 30
.Font.Size = 20
.Caption = ActiveCell.Value & " Info"
.Font.Bold = True
.ForeColor = vbBlue
.TextAlign = fmTextAlignCenter
.Left = (SamInf.InsideWidth - .Width) / 2
End With
End Sub
Last edited: