Hi there. thanks in advance for looking in
I have a userform with 6 checkboxes.
Users need to select 2 - if they try to select 3 (msgbox) but how can i make the msgbox appear when a user attempts to tick a 3rd box rather than on a command click?
Moving on : Once they select 2 checkboxes, i need to determine which 2 boxes were checked out of the 6.
This was the old code i had - but i am not sure how to modify it.
Any help will be really appreciated:
'''''''' Now there will be 6 checkboxes and i am not sure how to modify the code below so that message appears only if user tries to tick 3rd box
'''''''' The rest of the code
'''''''' The 6 checkboxes are named as follows :M1, M5, M30, H1, H4, D1I now need to modify the code below to determine which 2 out of the 6 boxes were checked instead of just simply adding h1 to the end of the name (as marked in red below) :
Then i believe i will need to modify this code below for filling the listboxes but i cant get my head round how to do it :
'''''''' Right now its adding h1 to the end of the name from a cell on the sheet. But I would like to modify these codes so that the listbox is populated depending on what the user checked instead. IE, user ticks checkbox M5, so m5 gets added to the end of the name for populating Listbox1 - then for 2nd checkbox that user ticks, eg, D1, then d1 gets added to the end of the name for populating Listbox2.
Thanks so so so much in advance if anyone can help me figure this out
Hope it all makes sense.
I have a userform with 6 checkboxes.
Users need to select 2 - if they try to select 3 (msgbox) but how can i make the msgbox appear when a user attempts to tick a 3rd box rather than on a command click?
Moving on : Once they select 2 checkboxes, i need to determine which 2 boxes were checked out of the 6.
This was the old code i had - but i am not sure how to modify it.
Any help will be really appreciated:
'''''''' Now there will be 6 checkboxes and i am not sure how to modify the code below so that message appears only if user tries to tick 3rd box
Private Sub cmdChartOK_Click()
If CheckBox4.Value = 0 Then
MsgBox "You can only select 2 charts per trade", vbExclamation
Exit Sub
End If
'''''''' The rest of the code
Dim wb As Workbook, ws As Worksheet
Dim fso As Object, f As Object
Dim dfound As Boolean, hfound As Boolean
On Error GoTo ErrHandler
Set fso = CreateObject("scripting.filesystemobject")
Set wb = ActiveWorkbook
Set ws = ActiveSheet
dfound = False
hfound = False
'''''''' The 6 checkboxes are named as follows :M1, M5, M30, H1, H4, D1I now need to modify the code below to determine which 2 out of the 6 boxes were checked instead of just simply adding h1 to the end of the name (as marked in red below) :
For Each f In fso.getfolder("C:\documents and settings\" & Environ("USERNAME") & "\desktop\Trade Logs\Chart Pictures").Files
If UCase(ws.Range("B" & ActiveCell.Row).Value & "h1") = UCase(Left(f.ShortName, InStr(f.ShortName, ".") - 1)) Then
ws.Range("i" & ActiveCell.Row).Hyperlinks.Add ws.Range("i" & ActiveCell.Row), f.Path, , , f.Name
hfound = True
Exit For
End If
Next f
If hfound = False Then
MsgBox "Requested Chart Not Found"
ws.Range("i" & ActiveCell.Row) = "No Chart"
ws.Range("i" & ActiveCell.Row).Hyperlinks.Delete
With ws.Range("i" & ActiveCell.Row)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Interior.ColorIndex = 43
End With
With ws.Range("i" & ActiveCell.Row).Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
With ws.Range("i" & ActiveCell.Row).Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
End With
End If
Then i believe i will need to modify this code below for filling the listboxes but i cant get my head round how to do it :
Rich (BB code):
With ListBox1
.Font.Bold = True
.AddItem Sheets("Mini Forex").Range("B" & ActiveCell.Row).Value & "h1.gif"
.Height = 20
End With
'''''''' Right now its adding h1 to the end of the name from a cell on the sheet. But I would like to modify these codes so that the listbox is populated depending on what the user checked instead. IE, user ticks checkbox M5, so m5 gets added to the end of the name for populating Listbox1 - then for 2nd checkbox that user ticks, eg, D1, then d1 gets added to the end of the name for populating Listbox2.
With ListBox2
.Font.Bold = True
.AddItem Sheets("Mini Forex").Range("B" & ActiveCell.Row).Value & "d1.gif"
.Height = 20
End With
Thanks so so so much in advance if anyone can help me figure this out
Hope it all makes sense.
Last edited: