ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   If then and 2 cell values (https://www.excelbanter.com/excel-programming/332936-if-then-2-cell-values.html)

John

If then and 2 cell values
 
I am trying to run the following statement... which works fine for whatever
my N6 value is. however, I would like it to run the same way if either cell
N6 or O6 has the conditional properties in the statment. Do I need to run
some sort of loop? Can I put in an "OR" so that ... If Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked with VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!

Tom Ogilvy

If then and 2 cell values
 
If Len(Range("n6").Value) = 3 or _
len(Range("O6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf Range("n6").Value = "fedl" _
or Range("O6").Value = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

--
Regards,
Tom Ogilvy


"John" wrote in message
...
I am trying to run the following statement... which works fine for

whatever
my N6 value is. however, I would like it to run the same way if either

cell
N6 or O6 has the conditional properties in the statment. Do I need to run
some sort of loop? Can I put in an "OR" so that ... If Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked with

VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!




John

If then and 2 cell values
 
Tom, thanks your statment works, but I have a new issue due to the nature of
the way I described the issue. If between N6 and O6 ...only one of the cells
meets the conditions of the If Then statement, then the statement works. If
both N6 and O6 have values that meet one of the conditions then the statement
will not work. IE - If N6 len = 3 and O6 = "fedl""... am I making myself
clear? Will I need to run another If then statement?


"Tom Ogilvy" wrote:

If Len(Range("n6").Value) = 3 or _
len(Range("O6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf Range("n6").Value = "fedl" _
or Range("O6").Value = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

--
Regards,
Tom Ogilvy


"John" wrote in message
...
I am trying to run the following statement... which works fine for

whatever
my N6 value is. however, I would like it to run the same way if either

cell
N6 or O6 has the conditional properties in the statment. Do I need to run
some sort of loop? Can I put in an "OR" so that ... If Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked with

VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!





John

If then and 2 cell values
 
Tom,

I think this is an application issue, where the number of {TABS} I send
changes if both conditions are true...


"John" wrote:

Tom, thanks your statment works, but I have a new issue due to the nature of
the way I described the issue. If between N6 and O6 ...only one of the cells
meets the conditions of the If Then statement, then the statement works. If
both N6 and O6 have values that meet one of the conditions then the statement
will not work. IE - If N6 len = 3 and O6 = "fedl""... am I making myself
clear? Will I need to run another If then statement?


"Tom Ogilvy" wrote:

If Len(Range("n6").Value) = 3 or _
len(Range("O6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf Range("n6").Value = "fedl" _
or Range("O6").Value = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

--
Regards,
Tom Ogilvy


"John" wrote in message
...
I am trying to run the following statement... which works fine for

whatever
my N6 value is. however, I would like it to run the same way if either

cell
N6 or O6 has the conditional properties in the statment. Do I need to run
some sort of loop? Can I put in an "OR" so that ... If Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked with

VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!





Tom Ogilvy

If then and 2 cell values
 
Then you would have to spell out what to do in each instance.

--
Regards,
Tom Ogilvy


"John" wrote in message
...
Tom, thanks your statment works, but I have a new issue due to the nature

of
the way I described the issue. If between N6 and O6 ...only one of the

cells
meets the conditions of the If Then statement, then the statement works.

If
both N6 and O6 have values that meet one of the conditions then the

statement
will not work. IE - If N6 len = 3 and O6 = "fedl""... am I making myself
clear? Will I need to run another If then statement?


"Tom Ogilvy" wrote:

If Len(Range("n6").Value) = 3 or _
len(Range("O6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf Range("n6").Value = "fedl" _
or Range("O6").Value = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

--
Regards,
Tom Ogilvy


"John" wrote in message
...
I am trying to run the following statement... which works fine for

whatever
my N6 value is. however, I would like it to run the same way if

either
cell
N6 or O6 has the conditional properties in the statment. Do I need to

run
some sort of loop? Can I put in an "OR" so that ... If

Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked

with
VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!







John

If then and 2 cell values
 
Yep, thanks for the help


"Tom Ogilvy" wrote:

Then you would have to spell out what to do in each instance.

--
Regards,
Tom Ogilvy


"John" wrote in message
...
Tom, thanks your statment works, but I have a new issue due to the nature

of
the way I described the issue. If between N6 and O6 ...only one of the

cells
meets the conditions of the If Then statement, then the statement works.

If
both N6 and O6 have values that meet one of the conditions then the

statement
will not work. IE - If N6 len = 3 and O6 = "fedl""... am I making myself
clear? Will I need to run another If then statement?


"Tom Ogilvy" wrote:

If Len(Range("n6").Value) = 3 or _
len(Range("O6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf Range("n6").Value = "fedl" _
or Range("O6").Value = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

--
Regards,
Tom Ogilvy


"John" wrote in message
...
I am trying to run the following statement... which works fine for
whatever
my N6 value is. however, I would like it to run the same way if

either
cell
N6 or O6 has the conditional properties in the statment. Do I need to

run
some sort of loop? Can I put in an "OR" so that ... If

Len(Range("n6") OR
("o6").Value) = 3 Then......
I think I need to run a loop that will run, but I have only worked

with
VBA
for a couple of weeks so I am not exactly sure.

If Len(Range("n6").Value) = 3 Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
ElseIf (Range("n6").Value) = "fedl" Then
SendKeys "{TAB}"
SendKeys "{TAB}"
SendKeys "{TAB}"
Else:
SendKeys "{TAB}"
SendKeys "{TAB}"
End If

Thanks for the help!!!








All times are GMT +1. The time now is 02:04 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com