|
-
Aug 14th, 2012, 05:20 PM
#1
Thread Starter
New Member
-
Aug 14th, 2012, 05:24 PM
#2
Thread Starter
New Member
Re: Call ComboBox
New picture:
-
Aug 14th, 2012, 05:29 PM
#3
Thread Starter
New Member
Re: Call ComboBox
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
-
Aug 14th, 2012, 05:39 PM
#4
Re: Call ComboBox
Welcome to VBForums 
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
-
Aug 15th, 2012, 04:54 AM
#5
Re: Call ComboBox
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?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Aug 15th, 2012, 06:04 AM
#6
Thread Starter
New Member
Re: Call ComboBox
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
-
Aug 15th, 2012, 08:38 AM
#7
Re: Call ComboBox
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
-
Aug 17th, 2012, 05:21 AM
#8
Thread Starter
New Member
Re: Call ComboBox

Thanks,just what I needed........
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|