Syntax error when trying to make a drop down list hidden if certain values are selected

benprelf

New Member
Joined
Aug 28, 2014
Messages
34
I am trying to hide a userform when certain values from a drop down list matching a range of text are selected.

If the dropdown choice contains a different value than what is stored in the range I'd like the userform to be shown.

Code:
[B]Sub EXMProceed2_Click()[/B]


[B]Dim CheckFibre As String[/B]
[B]Dim FibreInsertsVBA As String[/B]

[B]CheckFibre = Worksheets("CreateConnectorEXM").range("J10") 'Drop down list[/B]
[B]FibreInsertsVBA = Worksheets("DATA").range("FibreInserts")     'Data Range is named "FibreInserts" via the excel name manager functions[/B]

[B]If CheckCable = ("MM") And CheckFibre <> FibreInsertsVBA Then[/B]
[B]FiberArrangements.Show[/B]
[B]    Else[/B]

[B].....[/B]

[B]End If 
[/B]

It is returning a Syntax error, any help would be much appreciated.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Code:
FibreInsertsVBA = Worksheets("DATA").range("FibreInserts")

This is the line causing the error. The latest error is a "type mismatch" with this line.

Apologies I am not sure what you mean by the range being in the lower case rather than the proper case.
 
Upvote 0
Apologies, when I use the term "range" it automatically goes to lowercase. There is a procedure in the workbook named "Range" in the proper case however when I use it in the code it auto corrects itself to lowercase.

The code works if I take out the "range" and replace it with a single text value. I just can't seem to get it to work for the rest.

Code:
Dim CheckCable As String
Dim CheckFibre As String
Dim FibreInserts As Variant


CheckCable = ActiveSheet.range("D10")
CheckFibre = Worksheets("CreateConnectorEXM").range("J10")
FibreInserts = Worksheets("DATA").range("A6:A11").Value 'There is a group of cells on this worksheet under the title FibreInsertsVBA but when I reference this group nothing happens.

If CheckCable = ("MM") And CheckFibre <> FibreInserts Then

FiberArrangements.Show
    Else
 
Upvote 0
If I remove Range I receive a "Type mismatch" error on this line:

Code:
If CheckCable = ("MM") And CheckFibre <> FibreInserts Then
 
Upvote 0
Does this work for you?

Rich (BB code):
    Dim CheckCable As String
    Dim CheckFibre As String
    Dim FibreInserts As Range
    CheckCable = ActiveSheet.Range("D10").Value
    CheckFibre = Worksheets("CreateConnectorEXM").Range("J10").Value
    Set FibreInserts = Worksheets("DATA").Range("A6:A11")
    If CheckCable = "MM" And WorksheetFunction.CountIf(FibreInserts, CheckFibre) = 0 Then
 
Upvote 0

Forum statistics

Threads
1,203,400
Messages
6,055,179
Members
444,768
Latest member
EMGVT

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