selected toggle buttons to fill in worksheet

donny1shot

New Member
Joined
Mar 8, 2018
Messages
18
Hi all,
I am trying to use toggle buttons to fill in part of a work sheet and I am trying to get if either one or more are selected the those captions will auto fill a particular cell. However my current code only fills in the final if please help.
 

Some videos you may like

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,843
Office Version
  1. 2013
Platform
  1. Windows
We need details.
Show us your code
 
Last edited:

donny1shot

New Member
Joined
Mar 8, 2018
Messages
18
Private Sub CommandButton1_Click()
If Apollo.Enabled Then
Sheets("sheet2").Range("d5") = Apollo.Caption

End If

End Sub


That is the current code and I just tried to copy and past it and change the names to suit each toggle. but that didn't work.

sorry I am a real newbie at this.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,843
Office Version
  1. 2013
Platform
  1. Windows
Explain in more detail what you want. With specifics.
 

donny1shot

New Member
Joined
Mar 8, 2018
Messages
18

ADVERTISEMENT

Explain in more detail what you want. With specifics.

so I have a userform on which I have multiple toggle buttons and when one or more is selected upon clicking my command button I would like all selected toggles to have their respective captions fill in a cell on my worksheet. so for example one of the toggles is named Apollo (as in above code) and that is the caption.

Currently when his is selected alone and I click the command button it fills in the corresponding cell. However I want any button within that section of the form to fill in the cell when multiple are selected they will all fill in that cell

example of the code how I put it previously but only filled in the latter to the cell.
Private Sub CommandButton1_Click()
If Apollo.Enabled Then
Sheets("sheet2").Range("d5") = Apollo.Caption

End If
If Jupiter.Enabled Then
Sheets("sheet2").Range("d5") = Jupiter.Caption

End If

End Sub
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,843
Office Version
  1. 2013
Platform
  1. Windows
So if you have 10 Toggle buttons and all 10 are enable then you want Range("D5" to have 10 ToggleButton captions entered into "D5"

And how do you enable and then unenable your toggle buttons?

Or do you mean if the toggle button is selected which means is True or False

Your subject title says "Selected" not "Enabled" there is a different.

Enable means it set to work unenabled means it will not work
 
Last edited:

donny1shot

New Member
Joined
Mar 8, 2018
Messages
18

ADVERTISEMENT

Yes exactly if ten toggles are selected (true) then they will all enter into that cell. that is all I need to know FOR NOW AT LEAST haha.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,843
Office Version
  1. 2013
Platform
  1. Windows
Yes exactly if ten toggles are selected (true) then they will all enter into that cell. that is all I need to know FOR NOW AT LEAST haha.

Do you want "D5" to look like this:
Apollo
George
Bob
Jane
Jack

Or like
Apollo George Bob Jane Jack
And if like this do we need spaces between each word.
Another case of needing details.


And see you original used the term Enabled and now your using selected = True
It's always important to have specific details

And when you use 10 toggle buttons how do you know which ones are selected and which ones are not selected visually. I see no differents in how the look.

Are you sure this is the best way to do what you want? Why would not selecting values in a listbox be easier.

You can have one listbox select multiple values in the listbox and when you press a button all those values you selected in the listbox would be entered into "D4"

It's a listbox set so you can select multiple items.
 

donny1shot

New Member
Joined
Mar 8, 2018
Messages
18
I think I could work using list boxes instead of the toggles to be fair might be easier. In simple terms I am trying to create a one trick form that allows my peers to fill in order forms with handwriting or using our current erp as it's crap so one form to cover all options basically.

But yeah list boxes should work fine I think/ hope.
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,843
Office Version
  1. 2013
Platform
  1. Windows
Not sure what this means:
trying to create a one trick form

You never answered how you want these values entered into "D4"

And give me a list of the possible choices to choose from. Like the captions of the Toggle buttons.

And your using a UserForm correct?

And all we will ever be doing is entering values into Range ("D4") is that correct?

Do not assume you will be able to figure things out later to fit your needs.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,250
Messages
5,527,633
Members
409,778
Latest member
MagalieD

This Week's Hot Topics

Top