VBA IF with to many Or's

Weeble

Board Regular
Joined
Nov 30, 2016
Messages
95
Office Version
  1. 365
Code:
If (P10Text.Value = "*" Or P20Text.Value = "*" Or P30Text.Value = "*" Or P31Text.Value = "*" Or PLText.Value = "*") Then
    Worksheets("PlockSnitt").Activate

Could anyone give me a suggestion on how to write this statement in a better way?
Does not work that great for me. Basicly I need if the value in the textboxes are greater than 0 It must execute a series of lines.
I've tried replacing with P10Text.Value > 0 , but can't get the code to run properly.
Probably having so many Or's is not ideal i'm guessing?
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
They are all numbers.

The IF statement later runs this.
Code:
 Cells(emptyRow2, 6).Value = CDbl(Replace(P10snitt, ".", ","))
 
Upvote 0
Try
Code:
If CDbl(P10Text.Value) > 0 Or CDbl(P30Text.Value) > 0
 
Upvote 0
I tried this
Code:
If CDbl(P10Text.Value) > 0 Or CDbl(P20Text.Value) > 0 Or CDbl(P30Text.Value) > 0 Or CDbl(P31Text.Value) > 0 Or CDbl(PLText.Value) > 0 Then
    Worksheets("PlockSnitt").Activate
And even though the textboxes are blank he still runs the IF code.
Feels like i'm missing something
 
Upvote 0
With the way that's written, if ANY of the textboxes have a value> 0 then it will activate the sheet.
if you want all the textboxes to have a value, then change Or to And
 
Upvote 0
Thx Fluff,
I must have an error somewere else in the code then :)
Atleast now I know this part is true.
 
Upvote 0

Forum statistics

Threads
1,215,641
Messages
6,125,979
Members
449,276
Latest member
surendra75

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