Question description:
This user has given permission to use the problem statement for this
blog.
Sub Query()
Dim ws As Worksheet
combo_box1.Value = "Sheet2" Or "Sheet1" Or "Sheet3" Or "Sheet5"
If Sheet2 = combo_box1.Value Then
Worksheets("Sheet2").Activate = True
End If
If Sheet1 = combo_box1.Value Then
Worksheets("Sheet1").Activate = True
End If
If "Sheet3" = combo_box1.Value Then
Worksheets("Sheet3").Activate = True
End If
If "general" = combo_box1.Value Then
Worksheets("general").Activate = True
End If
If "Sheet5" = combo_box1.Value Then
Worksheets("Sheet5").Activate = True
End If
End Sub
Why am I getting an error called "Runtime Error- Object does not support this property or method
Solved by F. C. in 29 mins
This is the chat thread from the real Excelchat help session. It contains no private user
information.
Excelchat Expert
23/10/2017 - 02:21
HI, It's pleasure to help you today:)
User
23/10/2017 - 02:21
hello
Excelchat Expert
23/10/2017 - 02:21
Please attach the file in the chat
User
23/10/2017 - 02:21
sure
User
23/10/2017 - 02:22
it is not letting me paste an xlsm file
Excelchat Expert
23/10/2017 - 02:23
Can you please upload to google drive and share the link
Excelchat Expert
23/10/2017 - 02:23
or dropbox link
User
23/10/2017 - 02:25
https://drive.google.com/drive/my-drive
Excelchat Expert
23/10/2017 - 02:26
Please right click on the uploaded file and get the shareable link
User
23/10/2017 - 02:27
https://drive.google.com/file/d/0B6qFXYOIedhsNjV1c0h0VE9rTjA/view?usp=sharing
Excelchat Expert
23/10/2017 - 02:27
Thanks. I got the file
Excelchat Expert
23/10/2017 - 02:28
I will open it shortly
Excelchat Expert
23/10/2017 - 02:28
Where can i see the combobox?
User
23/10/2017 - 02:29
the combobox is in the general sheet
User
23/10/2017 - 02:29
its a drop down for choosing the sheet
Excelchat Expert
23/10/2017 - 02:29
That is not combobox1. It is just a data validation dropdown containing the list
Excelchat Expert
23/10/2017 - 02:30
Ok. I am checking it
User
23/10/2017 - 02:30
oh alright sorry I have listed vba knowledge I was told by someone that this a combobox
Excelchat Expert
23/10/2017 - 02:30
Ok. Basically, you are trying to active the sheet based on the selection
User
23/10/2017 - 02:31
yes
User
23/10/2017 - 02:31
that is spot on
Excelchat Expert
23/10/2017 - 02:31
Ok. I will work on this quickly. Hope, you are not changing the cell of dropdown
Excelchat Expert
23/10/2017 - 02:31
That is Cell A5
User
23/10/2017 - 02:31
I would not
Excelchat Expert
23/10/2017 - 02:32
ok
User
23/10/2017 - 02:32
I hope you are not planning of using a hyperlink?
Excelchat Expert
23/10/2017 - 02:33
No. I will use a button for this
Excelchat Expert
23/10/2017 - 02:33
Sheet 3 is not available
Excelchat Expert
23/10/2017 - 02:33
So, there is a possible chance of error
User
23/10/2017 - 02:33
if possible could you just remove it from the code?
Excelchat Expert
23/10/2017 - 02:34
Sure. will do that
User
23/10/2017 - 02:34
thank you
Excelchat Expert
23/10/2017 - 02:36
Ok. It's done. I have reduced to one line of code
Excelchat Expert
23/10/2017 - 02:36
Sheets(Sheets("general").Range("A5")).Select
User
23/10/2017 - 02:36
oh? could I have a look at the file please
Excelchat Expert
23/10/2017 - 02:36
https://www.dropbox.com/s/nvnwpj5dshuvsn4/Query.xlsm?dl=0
Excelchat Expert
23/10/2017 - 02:36
Please download from this link
Excelchat Expert
23/10/2017 - 02:38
click on the blue colour button
User
23/10/2017 - 02:38
sorry bro I am getting a run time erro
User
23/10/2017 - 02:38
but*
User
23/10/2017 - 02:39
run time error 13
Excelchat Expert
23/10/2017 - 02:39
ok. Just change the code as follows
Excelchat Expert
23/10/2017 - 02:39
Sheets(Sheets("general").Range("A5").Text).Select
Excelchat Expert
23/10/2017 - 02:39
add ".text" after range("A5")
User
23/10/2017 - 02:40
It is working
Excelchat Expert
23/10/2017 - 02:40
Great to hear that
User
23/10/2017 - 02:40
could you please describe how you did it
Excelchat Expert
23/10/2017 - 02:41
I am just getting the text in cell A5 from sheet called general
Excelchat Expert
23/10/2017 - 02:41
A one line code is sufficient
Excelchat Expert
23/10/2017 - 02:41
Whatever sheet name is there in the cell A5, it will be selected automatically
User
23/10/2017 - 02:42
how did you put the button in the sheet which programs everything
Excelchat Expert
23/10/2017 - 02:42
It is from shapes
Excelchat Expert
23/10/2017 - 02:42
Insert a shape and right click on this and click on assign macro
Excelchat Expert
23/10/2017 - 02:42
and select Query program
Excelchat Expert
23/10/2017 - 02:45
Hope, i have addressed all the requirements as mentioned in the description
User
23/10/2017 - 02:46
yes
Excelchat Expert
23/10/2017 - 02:46
Thank you
User
23/10/2017 - 02:46
I understand you have solved the problem
Excelchat Expert
23/10/2017 - 02:46
Have a great day ahead:)
Excelchat Expert
23/10/2017 - 02:46
Please visit Got it Pro for new queries
User
23/10/2017 - 02:46
could you please tell me what was wrong with my code though
Excelchat Expert
23/10/2017 - 02:47
Hi, I tried to simply the code. combobox is not avaiable first of all.
Excelchat Expert
23/10/2017 - 02:47
So, i felt, it is easy to make in one line code
User
23/10/2017 - 02:48
what does that error mean though?
User
23/10/2017 - 02:48
expected function or variable
User
23/10/2017 - 02:48
compile error
Excelchat Expert
23/10/2017 - 02:48
When it is not found that element, it gives that error. The same error can appear for different cases.
Excelchat Expert
23/10/2017 - 02:49
The declaraion of combobox1.value will give error, as it does not find combo box.
User
23/10/2017 - 02:49
ah alright
Excelchat Expert
23/10/2017 - 02:49
May be some one has guided you wrongly saying that it is combobox
User
23/10/2017 - 02:49
alright
User
23/10/2017 - 02:49
thanks a lot for your help
Excelchat Expert
23/10/2017 - 02:49
Please end the session and leave a 5-star review. Thank you.
This is the output file from the real Excelchat help session:
This is an example of the expert help you can get. It contains no private user
information.