Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 VBA Conditions(last edit)
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 VBA Conditions(last edit)
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" --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
3 VBA Conditions(last edit)
Thank you. This helped.
-----Original Message----- 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" --- Message posted from http://www.ExcelForum.com/ . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Countif Conditions - Use of conditions that vary by cell value | Excel Discussion (Misc queries) | |||
2 Conditions + Sum of a colum matching those conditions | Excel Worksheet Functions | |||
shade cells based on conditions - i have more than 3 conditions | Excel Worksheet Functions | |||
Why can't I edit my excel document? Edit buttons shaded. | New Users to Excel | |||
How to multiple conditions to validate more than 2 conditions to . | Excel Worksheet Functions |