3 VBA Conditions(last edit)

  • Thread starter Thread starter Todd Huttenstine
  • Start date Start date
T

Todd Huttenstine

I have Range O2:O100 and P2:R100. The below code
looks in Range P2:R100 and if it finds a % in any of the
values, will offset into the corresponding cell in Range
O2:O100 and will put the value "percent" in the cell
itself. If it cannot find a % in any of the values in
Range P2:R100, will offset into the corresponding cell in
Range O2:O100 and will put the value "number" in the cell
itself.


Dim c As Range
For Each c In Range("O2:O100").Cells
With c
If InStr(1, .Offset(,
1).NumberFormat, "%") Or _
InStr(1, .Offset(, 2).NumberFormat, "%")
Or _
InStr(1, .Offset(, 3).NumberFormat, "%")
Then
.Value = "percent"
Else
.Value = "number"
End If
End With
Next c

Instead I need the code to perform the following. There
are a total of 3 conditions. The first condition is the %
condition which has already been addressed. The 2nd
condition is the time format. If it finds a : value in
Range P2:R100, I need it to offset into the corresponding
cell in Range O2:O100 and put the value "time" in the cell
itself.

And last, if it does not find a % or a : in any of the
value in Range P2:R100, then I need for it to offset into
the corresponding cell in Range O2:O100 and put the the
value "number" in the cell itself.



Thanx
 
The basic structure here would be :-

'----------------------------------------------
If .......... Then
'code
ElseIf ............ Then
'code
ElseIf ........... Then
'code
Else
'code
End If
'-----------------------------------------

You could presumably do a similar search for ":" to get time, or you
might find this useful :-

If IsNumber(c.Value) Then c.Value = "number"
 
Back
Top