Refer to a combobox in another sheet

MrThor

New Member
Joined
Aug 13, 2018
Messages
36
Hi, I want to refer to a combobox on another sheet. I want to be able to click the cell F5 in and things will happen depending to the combobox value. Is there a way to write this code on another sheet and still get it to work?

Heres my code, it works when I am on the same sheet. The code shall be at sheet2 and now it is in sheet1 (Dagbok). Can it be removed to sheet2?

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

Dim sh2 As Worksheet
Set sh2 = Worksheets("Blad2")
Dim sh1 As Worksheet
Set sh1 = Worksheets("Dagbok")




If Not Application.Intersect(Target, sh1.Range("F5")) Is Nothing And Me.ComboBox1.Value = "Jan" Then
Jan5.Show


sh1.Range("A13:A21").Value = sh2.Range("B34:B43").Value
sh1.Range("B13:B21").Value = sh2.Range("C34:C43").Value
sh1.Range("D13:D21").Value = sh2.Range("E34:E43").Value
End If




End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Try something like this:
Code:
Sub My_Plan()
'Modified  8/15/2018  5:26:08 PM  EDT
Sheets(2).ComboBox1.Value = "Carl"
End Sub
 
Upvote 0
Try this:
Code:
If Not Application.Intersect(Target, sh1.Range("F5")) Is Nothing And Sheets(2).ComboBox1.Value = "Jan" Then
Jan5.Show
 
Upvote 0
So your saying you have a combobox on Sheet(2) named Combobox1 and you have Jan in the combobox and that is all.

If not please explain where is this combobox. Do not say on another sheet. Give me the sheet name
 
Upvote 0
Ok I have the combobox on sheet1 and I want to make this code in sheet2. The problem is when I am searching for it in sheet two I can obviously not find it so I need to be able to reffer it in some way but I dont know how.
 
Upvote 0
Your script says this:
Set sh2 = Worksheets("Blad2")
Dim sh1 As Worksheet
Set sh1 = Worksheets("Dagbok")
So it looks like to me your sheets are not named Sheet1 and sheet2


I need you to tell me the sheet name you want this script to run in
And the sheet name with the Combobox


I need to see the names like this

Sheet name "Me"

And sheet name "You"

Put the actual sheet name in quotes like i did
 
Upvote 0

Forum statistics

Threads
1,224,828
Messages
6,181,204
Members
453,022
Latest member
RobertV1609

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