Previous in Forum: Why Does My Spelling Errors File Not Work?   Next in Forum: Which Program Should I Use?
Close
Close
Close
7 comments
Rate Comments: Nested
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119

Toggle "STAR" to "DELTA" in Command Button Using VBA

09/23/2013 5:10 AM

In Excel 2007 I make an application using VBA.

I place a command button along with a combobox. The caption of the command button shows " STAR " when the userform2 open and the combobox appear at that time. Now, if I click on the command button then it changes to "DELTA" and combobox disappear.

Now, if I again click on the command button then "STAR" and comboboxnot appear.

Please help me how I can do it.

Register to Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Guru
United Kingdom - Member - Indeterminate Engineering Fields - Control Engineering - New Member

Join Date: Jan 2007
Location: In the bothy, 7 chains down the line from Dodman's Lane level crossing, in the nation formerly known as Great Britain. Kettle's on.
Posts: 32175
Good Answers: 839
#1

Re: Toggle "STAR" to "DELTA" in command button using VBA

09/23/2013 7:29 AM

FactoryTalk 32 would be a better platform for doing this sort of thing than Excel.

Change the package.

__________________
"Did you get my e-mail?" - "The biggest problem in communication is the illusion that it has taken place" - George Bernard Shaw, 1856
Register to Reply
Guru
Popular Science - Weaponology - New Member Netherlands - Member - New Member Fans of Old Computers - Commodore 64 - New Member

Join Date: Sep 2007
Location: Japan
Posts: 2703
Good Answers: 38
#2

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

09/23/2013 9:23 PM

There is something wrong with your code, post or as on a programming forum.

(check in the code of the button if the appropriate functions are called)

__________________
From the Movie "The Big Lebowski" Don't pee on the carpet man!
Register to Reply
Guru

Join Date: Nov 2007
Location: Eastern Arizona mountains on Route 666 about a mile from God's country
Posts: 1676
Good Answers: 122
#3

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

09/24/2013 8:56 AM

Invoke debugger and watch the code algorithms execute then correct the error.

If you cannot understand it, post the algoritms and someone can help you.

__________________
They said; "Brain size?" I heard; "Train size?" so I said: "I'll take a small one, thank you."
Register to Reply
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119
#4
In reply to #3

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

09/25/2013 7:00 AM

My VBA Code is:

Initially CommandButton1.caption="STAR"

Private Sub CommandButton1_Click()

If CommandButton1.Caption="STAR" then

CommandButton1.Caption="DELTA"

ComboBox1.visible=False

End if

If CommandButton1.Caption="DELTA" then

CommandButton1.Caption="STAR"

ComboBox1.visible=TRUE

End if

End Sub

Register to Reply
Guru
Popular Science - Weaponology - New Member Netherlands - Member - New Member Fans of Old Computers - Commodore 64 - New Member

Join Date: Sep 2007
Location: Japan
Posts: 2703
Good Answers: 38
#5
In reply to #4

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

09/25/2013 8:57 PM

Is this the copied code?

I always use these "{" after an if

In C++

if (test)

{

blalalala

}

I don't know VBA but in C++ without brackets only the line after the if statement is checked, also True or TRUE?

Also seeing this code the box caption should not change (or only briefly) because in the next if statement it would change it right back.

__________________
From the Movie "The Big Lebowski" Don't pee on the carpet man!
Register to Reply Score 1 for Off Topic
Power-User

Join Date: Feb 2011
Location: Shimurali, Westbengal,India
Posts: 119
#6
In reply to #5

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

09/26/2013 1:28 AM

I solve the problem.

thanks

Register to Reply
Power-User

Join Date: Oct 2008
Location: Troy, NY
Posts: 122
Good Answers: 4
#7

Re: Toggle "STAR" to "DELTA" in Command Button Using VBA

07/24/2017 4:53 PM

You should try using elseif in the middle part of the code instead of end if.

Elseif CommandButton1.Caption="DELTA" then

Register to Reply
Register to Reply 7 comments
Copy to Clipboard

Users who posted comments:

amitabha0107 (2); Epke (2); PWSlack (1); SHOCKHISCAN (1); terrapin (1)

Previous in Forum: Why Does My Spelling Errors File Not Work?   Next in Forum: Which Program Should I Use?

Advertisement