Need help with complex IF/Then

lbdyck

New Member
Joined
Apr 20, 2015
Messages
49
Here is my code:


If Flag = 2 Then
flag2 = 1
If IsEmpty("A" & i) Then flag2 = 0
If Range("A" & i) = "STRING 1" Then flag2 = 0
If Range("A" & i) = "STRING 2" Then flag2 = 0
If Range("A" & i) = "STRING 3" Then flag2 = 0
If flag2 = 1 Then
Call Proc_Text(array, i)
End If
End If


Where i is the row number that i'm processing and array is where i will put the data in the subroutine.


I only want to call the Proc_Text routine if the tested conditions are not met.


The data is a csv of information and the values in each row could be different so i'm looking only for those rows that start with a date and avoid those that are blank or have descriptive text.


Thank you
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
The correct syntax is

IF Condition THEN
'do something
ELSEIF Condition THEN
'do something
ELSEIF Condition THEN
'do something
ELSE
'do something
END IF


That being said I would look at SELECT CASE for this.
 
Last edited:
Upvote 0
Thank you - the elseif was helpful as it forced me to rewrite and i found my challenge with the logic.
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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