PDA

View Full Version : Using a click button to select data relating to checkboxes



N0ble
06-17-2010, 09:57 AM
Hi,

I have tried as much as i can with this and do not seem to be making progress.

My requirement is to have checkboxes which point to cell references.
Once the execute button is clicked I want the macro to look at the data that relates to each checkbox and select the data depending upon if the checkbox is true or false.

I have attached an xls to show as an example of what I would like to do, please note that I have stripped all the VB code as I think I was going in the wrong direction.

Thanks for any help.

Lee

Bob Phillips
06-17-2010, 10:17 AM
You can check them with



For Each cb In ActiveSheet.CheckBoxes

If cb.Value = 1 Then

End If
Next cb


But what do ypu want to do with the selected checkboxes.

N0ble
06-17-2010, 10:20 AM
I think you miss-understand?

I will manually select the check boxes and then for example.
If i have selected Contact list 1 and Contact list 3 check box, once i press the execute button i want it to highlight the data on the spreadsheet under Contact list 1 and Contact list 3 fields.

Bob Phillips
06-17-2010, 10:45 AM
Read what I said, I think you will find I understood perfectly



Dim rng As Range
Dim Highlight As Range
With ActiveSheet

For Each cb In .CheckBoxes

If cb.Value = 1 Then

Set rng = .Rows(1).Find(cb.Caption)
If Highlight Is Nothing Then

Set Highlight = Range(rng, rng.End(xlDown))
Else

Set Highlight = Union(Highlight, Range(rng, rng.End(xlDown)))
End If
End If
Next cb

If Not Highlight Is Nothing Then Highlight.Select
End With

N0ble
06-17-2010, 12:03 PM
Hi, i do apologize after re-reading i can see that you was just asking me exactly what i'm wanting to do with the check boxes.

Thank you so much, the suggested code has worked perfectly.
Much appreciated.

Lee

N0ble
06-17-2010, 12:25 PM
Hi,

Sorry to trouble you again.

How can i have contact list 1 as a permanent selection?
and is it possible to have the contact selections on the same column and select them but on multiple worksheets?

As displayed in the example?

Really appreciate your help.