|
-
Jan 12th, 2004, 06:55 AM
#1
Thread Starter
Hyperactive Member
VB- ComboBox
Code:
Sub Dropdown1_Change()
Dim s As String
Select Case Cells(1, 1).Value
Case 1
s = "C:\1.jpg"
Case 2
s = "C:\2.jpg"
End Select
ActiveSheet.Pictures.Insert s
End Sub
Can anyone make this code any simpler for having a ComboBox with pictures.
Thanx,
Greyskull
-
Jan 16th, 2004, 08:57 AM
#2
Well either of these are simpler in as much as less coding but I'd go with what you've got there to be honest - it'd perform just as well ...
VB Code:
Sub Dropdown1_Change()
Select Case Cells(1, 1).Value
Case 1
ActiveSheet.Pictures.Insert = "C:\1.jpg"
Case 2
ActiveSheet.Pictures.Insert = "C:\2.jpg"
End Select
End Sub
or
VB Code:
Sub Dropdown1_Change()
IF (Cells(1, 1).Value = 1) or (Cells(1, 1).Value = 2) then
ActiveSheet.Pictures.Insert = "C:\" & cstr(Cells(1, 1).Value) & ".jpg"
End If
End Sub
-
Jan 30th, 2004, 01:14 AM
#3
Banned
Neat...
Your code is really neat... I could learn a lot from it...
-
Mar 6th, 2004, 04:45 PM
#4
Supreme User
Any idea on loading these through Image List?
-
Mar 15th, 2004, 03:08 PM
#5
Registered User
Code:
Sub Dropdown1_Click()
ActiveSheet.Pictures.Insert "C:\" & Dropdown1.ListIndex & ".jpg"
End Sub
It may not be Dropdown1.ListIndex. It may be .Index or one of the other properties that gives the Index of the selected item in the Combo Box. Check it out. Also, check to make sure that the Index starts at 1. If not start naming your pics "C:\0.jpg"
-
Apr 6th, 2004, 02:43 PM
#6
Originally posted by HardCode
Code:
Sub Dropdown1_Click()
ActiveSheet.Pictures.Insert "C:\" & Dropdown1.ListIndex & ".jpg"
End Sub
It may not be Dropdown1.ListIndex. It may be .Index or one of the other properties that gives the Index of the selected item in the Combo Box. Check it out. Also, check to make sure that the Index starts at 1. If not start naming your pics "C:\0.jpg"
the ItemData property of the combo box is perfect for this... ItemData holds an integer value which can be any type... so you dont have to rely on the index which has to be ordered... you can have duplicate ItemData values... etc... and you can assign a value to a newly added item in the combo by referencing
Combo1.ListData(Combo1.NewIndex) = 10
its real good for when you want text data in a combo to correspond to an ID number in a database...
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
|