Help:blush:
I'm quite new to this and need help with the combobox.
How do i tell the combobox which module that has called it?
Want the combo selection to work on different shapes.
Attachment 90491
Tusen takk på forhånd ;)
Printable View
Help:blush:
I'm quite new to this and need help with the combobox.
How do i tell the combobox which module that has called it?
Want the combo selection to work on different shapes.
Attachment 90491
Tusen takk på forhånd ;)
New picture:
Attachment 90493
Try this instead:
Private Sub UserForm_Activate()
ComboBox1.AddItem "Item 1"
ComboBox1.AddItem "Item 2"
ComboBox1.AddItem "Item 3"
ComboBox1.AddItem "Item 4"
ComboBox1.Text = "Velg Riser"
End Sub
Private Sub ComboBox1_Click()
If Oval2 Then
If ComboBox1.Text = "Item 1" Then
Sheet1.Shapes("Oval 2").Fill.ForeColor.RGB = vbGreen
ElseIf ComboBox1.Text = "Item 2" Then
Sheet1.Shapes("Oval 2").Fill.ForeColor.RGB = vbBlue
End If
ElseIf Oval4 Then
If ComboBox1.Text = "Item 1" Then
Sheet1.Shapes("Oval 4").Fill.ForeColor.RGB = vbGreen
ElseIf ComboBox1.Text = "Item 2" Then
Sheet1.Shapes("Oval 4").Fill.ForeColor.RGB = vbBlue
End If
End If
Have two shapes called oval 2 and 4 and want to change colour on those depending of which shape i'm clicking on
End Sub
Welcome to VBForums :wave:
Thread moved to the 'Office Development/VBA' forum... note that while it certainly isn't made clear, the "VB Editor" in Office programs is actually VBA rather than VB, so the 'VB6' forum is not really apt
let me see if i understand what you want
you want to click an oval, then select a color from the combobox?
the oval is on a worksheet, not a userform?
That's right.
Have several ovals on the worksheet and want's to use the same combo box when I click on them.
Need some code to tell the which oval to perfom the change.
If I click on oval 2 I want the colour on oval 2 to change when and when I click oval 4 I want oval 4 to change.
The code works ,but how to tell which oval that called the userform?
Thanks
Here is some code to show how to determine which oval initiated the action. It doesn't do what you're asking, but should give you an idea how to proceed. You need to run it by clicking an oval; it won't work if you simply step through it in the editor.
Code:Sub ovals()
Dim wb As Workbook
Dim ws As Worksheet
Dim shpName As String
Dim shp As Shape
Set wb = Workbooks("ovals kurt.xlsm") 'your workbook name here
Set ws = wb.Sheets("sheet1") 'your sheet name here
shpName = ws.Shapes(Application.Caller).Name
Set shp = ws.Shapes(shpName)
shp.Left = shp.Left + 10 'moving the "calling" shape to demonstrate
End Sub
:)
Thanks,just what I needed........