Query | Listbox

thinksriniii

Board Regular
Joined
Apr 1, 2009
Messages
93
HI guys,

Can someone help me with this. I have inserted a listbox and based on the value selected a picture should be poped. I have searched the forum and got the code below. But it is throwing an error message "object required"

Private Sub ListBox1_Change()
If ListBox1.Value = "x" Then
Pictures("Picture 1").Visible = True
Else
Pictures("Picture 1").Visible = False
End If
End Sub

Then i modified it to
Sub ListBox1_Change()

If listbox1.Value = "1" Then
activesheets.Shapes("Picture 1").Visible = True
Else
activesheets.Shapes("Picture 1").Visible = False
End If
End Sub

still it is not working and the same error is thrown . can someone help
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Jus a information that i just inserted the test box in the sheet. BUt, i did not add any user form. Is that causing the error?

Dave
 
Upvote 0
Hi Dave

activesheets should be Activesheet ;)
 
Upvote 0
Dave,

Still throwing the same error "Object required". Just to reaffirm.. the picture 1 is present for sure..

Sub ListBox1_Change()
If listbox1.Value = "1" Then
ActiveSheet.Shapes("Picture 1").Visible = True
Else
ActiveSheet.Shapes("Picture 1").Visible = False
End If
End Sub

Dave
 
Upvote 0
I have this working

Code:
Private Sub ListBox1_Change()
If ListBox1.Value = "1" Then
ActiveSheet.Shapes("Picture 1").Visible = True
Else
ActiveSheet.Shapes("Picture 1").Visible = False
End If
End Sub

Picture 1 is there as is the number 1 option. Is Picture 1 on the active sheet?

EDIT:And the Sub needs to be Private Sub ;)
 
Upvote 0
Yes Dave.. Its on the active sheet

Think this line is causing problem. THis is highlight when the error is thrown

If listbox1.Value = "1" Then


Thanks for your help
 
Last edited:
Upvote 0
Where exactly is the code and the controls you want to work with located?
 
Upvote 0
Hi

Use the ListBox from the ActiveX content not the FormControls

Regards


Dave
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,381
Members
449,155
Latest member
ravioli44

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top