I have a userform that contains 15 labels, each label has Numbers in it each time i click on a label the text is inserted into an excel spreadsheet. I use it as a fast input solution and works well and has done for a few years.
I Now want to Add three checkboxes to the userform
If checkbox One is ticked i want the letter "A" and the number in the label i choose to be inserted into the spreadsheet.
Checkbox Two "B"
Checkbox Three "c"
I would only ever tick one of the checkboxes never two or three so it would be A, B or C
This is the code for The Labels i use
private Sub Label4_Click()
Call InsertTextSelection(Label4.Caption, RGB(0, 0, 255), 0)
End Sub
Private Sub Label5_Click()
Call InsertTextSelection(Label5.Caption, RGB(0, 0, 0), 0)
End Sub
and so on
This is the Call Insert textselection
Public Sub InsertTextSelection(text, colour, hours)
UserForm1.Hide
r = Selection.Row
c = Selection.Column
Range(Cells(r, c - 0), Cells(r, c - 0)).Select
With Selection
.ClearContents
.Font.Size = 9
.Font.Color = colour
.MergeCells = True
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.Value = text
End With
End Sub
The userform works by doubleclick
Hope you Can help
Dave
Bookmarks