basicallyawesome
New Member
- Joined
- Jul 10, 2018
- Messages
- 29
- Office Version
- 365
I am relatively new to VBA, which I've been using to solve basic problems and automate reasonably complex tasks for my workplace. My most complex one (so far!) is actually two documents: a data source housed in Excel and then the merge letter in Word. Rigging the Word document to do what I want it to was fairly easy, but I seem to have hit a wall with Excel.
While I understand IF statements as they pertain to formulas, I have yet to write one that actually works in VBA, and I think I require 2. Unfortunately I have no "real world" example because my work is protected under privacy legislation and confidentiality agreements, but the first one is basically:
If [Combobox].value = "Blurb2" then
Show.[B2Userform]
Elseif [Combobox].value = "Blurb3" then Show.[B3Userform]
...and so on, through roughly 18 "blurbs". Per various posts on here and other Excel/VBA forums, the code looks right but when I go to run it, I either get End If Without Block If or Else If Without If errors. I am completely lost on what I'm doing wrong, I've read basically everything and I still can't fix my problem.
The second one I need is more complex, and this didn't bring up any errors but also didn't do what I needed it to. It did... nothing.
If [Combobox].value = "Blurb2" then
[MainUserform].Hide
Elseif [Combobox].value = "Blurb3" then [MainUserform].Hide
...and again so on through the same roughly 18 "blurbs". The more I think about this one, the more I wonder if I truly need it. Will having the main user form in the background of the additional info/blurb userforms use a lot of memory overall?
If it makes a difference, both are supposed to be triggered by command buttons.
Thank you so much for any help you can provide! I've been reading this forum for a while now and have found it an invaluable resource.
While I understand IF statements as they pertain to formulas, I have yet to write one that actually works in VBA, and I think I require 2. Unfortunately I have no "real world" example because my work is protected under privacy legislation and confidentiality agreements, but the first one is basically:
If [Combobox].value = "Blurb2" then
Show.[B2Userform]
Elseif [Combobox].value = "Blurb3" then Show.[B3Userform]
...and so on, through roughly 18 "blurbs". Per various posts on here and other Excel/VBA forums, the code looks right but when I go to run it, I either get End If Without Block If or Else If Without If errors. I am completely lost on what I'm doing wrong, I've read basically everything and I still can't fix my problem.
The second one I need is more complex, and this didn't bring up any errors but also didn't do what I needed it to. It did... nothing.
If [Combobox].value = "Blurb2" then
[MainUserform].Hide
Elseif [Combobox].value = "Blurb3" then [MainUserform].Hide
...and again so on through the same roughly 18 "blurbs". The more I think about this one, the more I wonder if I truly need it. Will having the main user form in the background of the additional info/blurb userforms use a lot of memory overall?
If it makes a difference, both are supposed to be triggered by command buttons.
Thank you so much for any help you can provide! I've been reading this forum for a while now and have found it an invaluable resource.