Help
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.
Tusen takk på forhånd![]()
Help
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.
Tusen takk på forhånd![]()
New picture:
![]()
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
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
(2007, 2008, 2009, 2010, 2011, 2012) . . . . . . . . Hitchhiker's Guide to Getting Help at VBForums
Classic VB FAQs (updated Oct 2010) ...Database Development FAQs/Tutorials (updated May 2011)
(includes fixing common VB errors) .......... (includes fixing common DB related errors, and [Classic VB] ADO tutorial /further steps, and [VB.Net] ADO.Net Tutorial).
Tutorial: How to automate Excel from VB6 (or VB5/VBA) .•. SQL 'Select' statement formatter/checker .•. Convert colour number to colour name .•. FlexGrid: fill from recordset .•. FlexGrid: AutoSize columns .•. DB Reserved Words checker
Connection strings .•. MDAC/Jet/ACE downloads .•. SQL Server downloads .•. MZTools (free upgrade for the VB6/VBA Editor)
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
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........