HOW TO REMEMBER WHICH ITEM ON WHICH ROW YOU ADDED THE VALUE

jamielill

Active Member
Joined
Jul 27, 2009
Messages
286
Hi,
I have 30 check boxes per say, and if i set a check box to true it adds a numeric value to a list box.
Each checkbox has a value of 5
So if i click 5 checkbox s
my list box would be
5
5
5
5
5
What I want to do is remember which row each checkbox added the value so when I set false a checkbox it will remove it from the list box
So if i set checkbox 4 to false and this was added my third selection added to the list box it would remove row 3
5
5
5
5
Then all of the other position would change and have to be recorded.

Is there an easy way to do this?

thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Is there an easy way to do this?
The short answer is "No". You would need to use a helper list somewhere to track your changes to the checkboxes, ergo, the list box.. Maybe an additional column in the list box to shyow the last checkbox used for that value, or a two column range where the checkbox name and listbox position are cross referenced. But in either case it would take code to make and maintain the entries, which I have no desire to write. Maybe someone else has a better idea.
 
Upvote 0
If each checkbox puts 5 into the listbox, what difference does it make which one you remove? They're all the same
 
Upvote 0
If each checkbox puts 5 into the listbox, what difference does it make which one you remove? They're all the same
They will not be the same that is an example. I THINK I SHOULD USE A 2D MATRIX THEN REPOPULATE THE LIST BOX EACH TIME FROM THE MATRIX. UNLESS THETE IS A BETTER WAY
 
Upvote 0
You could do it like that, or as JLGWhiz suggested, have an extra column on the list box.

In future please do not SHOUT (using all capitals) as it is considered rude.
 
Upvote 0
Is there an easy way to do this?

A simple way is to put the 30 choices in the listbox.
You use the MultiSelect and ListStyle properties.
That way you don't have to remember the row or pass the data to the listbox.

1575726591775.png



Try this:

VBA Code:
Private Sub UserForm_Activate()
  Dim i As Long
  With ListBox1
    .MultiSelect = fmMultiSelectMulti
    .ListStyle = fmListStyleOption
    For i = 1 To 30
      .AddItem "choice " & i
    Next
  End With
End Sub
 

Attachments

  • 1575726435485.png
    1575726435485.png
    16.9 KB · Views: 4
Upvote 0
A simple way is to put the 30 choices in the listbox.
You use the MultiSelect and ListStyle properties.
That way you don't have to remember the row or pass the data to the listbox.

View attachment 1516


Try this:

VBA Code:
Private Sub UserForm_Activate()
  Dim i As Long
  With ListBox1
    .MultiSelect = fmMultiSelectMulti
    .ListStyle = fmListStyleOption
    For i = 1 To 30
      .AddItem "choice " & i
    Next
  End With
End Sub
Thank you every for you input
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0
The key issue is to remove the value that is tied to a specific row number. So the listbox values have to be cross referenced in some manner to the row at the time of entry, else there is not way to know which row prompted the checkbox to be clicked, nor where the entry was made in the listbox. The illustration in the OP is apparently not really representative of what one might see after check boxes are ticked, according to Post #4. So the OP wants to remove the value for the specific row that initiated the entry. Like I said, that will take some code to do the tracking of the initial entry and subsequent changes.
 
Upvote 0

Forum statistics

Threads
1,214,614
Messages
6,120,520
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top