Two options needed in one line of code

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,226
Office Version
  1. 2007
Platform
  1. Windows
Hi,
In my CoboBox5 there are various options.
Two of them need to show N/A

Ive done the below which works fine BUT as opposed to making a duplicate how can i also have another paramater in the same line.

Basically i need N/A applied to a worksheet cell if HISS CABLE ONLY or CLONE ONLY was selected
So like this example
If Me.ComboBox5.Value = "HISS CABLE ONLY" or "CLONE ONLY" Then



Here is the code.

Rich (BB code):
      If Me.ComboBox5.Value = "HISS CABLE ONLY" Then
      .Cells(8, 8).Value = "N/A"
      End If
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
VBA Code:
If Me.ComboBox5.Value = "HISS CABLE ONLY" Or Me.ComboBox5.Value = "CLONE ONLY" Then
      .Cells(8, 8).Value = "N/A"
End If
 
Upvote 0
I then get a compile error see screen shot
 

Attachments

  • EaseUS_2023_03_ 8_15_27_33.jpg
    EaseUS_2023_03_ 8_15_27_33.jpg
    31.9 KB · Views: 4
Upvote 0
See this of which doesnt give me any errors etc BUT when CLONE CHIP ONLY is selected it is supposed to enter N/A in row 8 cell 8 but when i check its empty.

If i select HISS CABLE ONLY then i do see N/A but my goal is N/A for either selection

Rich (BB code):
Private Sub ComboBox5_Change()
      With Worksheets("MCLIST")
      
If Me.ComboBox5.Value = "HISS CABLE ONLY" Then
      .Cells(8, 8).Value = "N/A"
      
ElseIf Me.ComboBox5.Value = "CLONE CHIP ONLY" Then
      .Cells(8, 8).Value = "N/A"
      
End If

End With
   If ComboBox5.Value = "HISS CABLE ONLY" Then
      Label9.Visible = False
      ComboBox8.Visible = False
      
   ElseIf ComboBox5.Value = "CLONE CHIP ONLY" Then
      Label9.Visible = False
      ComboBox8.Visible = False
      
End If
   
End Sub
 
Upvote 0
Did it have the With Worksheets("MCLIST")?

VBA Code:
With Worksheets("MCLIST")
    If Me.ComboBox5.Value = "HISS CABLE ONLY" Or Me.ComboBox5.Value = "CLONE ONLY" Then
          .Cells(8, 8).Value = "N/A"
    End If
end with
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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