zookeepertx
Well-known Member
- Joined
- May 27, 2011
- Messages
- 591
- Office Version
- 365
- Platform
- Windows
Hello all!
This is driving me crazy! All I want to do is have my macro open an existing workbook and call up a Userform with 2 option buttons so the user can select which of the 2 sheets in that workbook the rest of the macro will apply to.
It seems like it should be so easy, but I've been working on it most of yesterday afternoon and most of today so far and I don't seem to be any closer than when I started! Here's the (totally failed) code I have so far:
(The 2 lines are different because I keep trying different things on the first one, so it's already had a lot of different wording from the 2nd line as each attempt fails)
Right now the 1st line - the OptionButton1.Value line - is failing at "Then" and saying "Expected Expression". And that happens without even trying to RUN the thing! When I type that, it immediately gives the error message.
Please somebody help! I have the ENTIRE rest of the macro ready to hand over to my coworker if this part will just work. (I wrote the rest of it first because, so save time, I just wrote it to work with 2 sheets in the same workbook. Now I'm trying to make it recognize the ACTUAL workbooks/worksheets it needs to work on.)
I should say that this code is very short because I thought I'd just get the option buttons doing what they need to do, then put that bit of code into the existing macro. This may or may not be a good approach; feel free to correct me if it's a stupid idea.
Thanks!
Jenny
This is driving me crazy! All I want to do is have my macro open an existing workbook and call up a Userform with 2 option buttons so the user can select which of the 2 sheets in that workbook the rest of the macro will apply to.
It seems like it should be so easy, but I've been working on it most of yesterday afternoon and most of today so far and I don't seem to be any closer than when I started! Here's the (totally failed) code I have so far:
VBA Code:
Private Sub OptionButton1_Click()
If Me.OptionButton1.Value = Then Sheets("AB").Select
ElseIf OptionButton2.Value = True Then Worksheets("CD").Select
End If
Unload Me
End Sub
(The 2 lines are different because I keep trying different things on the first one, so it's already had a lot of different wording from the 2nd line as each attempt fails)
Right now the 1st line - the OptionButton1.Value line - is failing at "Then" and saying "Expected Expression". And that happens without even trying to RUN the thing! When I type that, it immediately gives the error message.
Please somebody help! I have the ENTIRE rest of the macro ready to hand over to my coworker if this part will just work. (I wrote the rest of it first because, so save time, I just wrote it to work with 2 sheets in the same workbook. Now I'm trying to make it recognize the ACTUAL workbooks/worksheets it needs to work on.)
I should say that this code is very short because I thought I'd just get the option buttons doing what they need to do, then put that bit of code into the existing macro. This may or may not be a good approach; feel free to correct me if it's a stupid idea.
Thanks!
Jenny