ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Code Edit (https://www.excelbanter.com/excel-programming/285237-code-edit.html)

Todd Huttenstine[_2_]

Code Edit
 
I have Range O2:O100 and P2:R100. The below code
currently looks in Range P2:P100 and if it finds a % in
the value,
will offset into the corresponding cell in Range O2:O100
and will put the % character in the cell itself.

Instead of the code only looking in Range P2:P100 for a %
in the value, I would like for the code to look in the
range expanded to P2:R100 for a % in the value.


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

Tom Ogilvy

Code Edit
 
If InStr(1, .Offset(, 1).NumberFormat, "%") or _
InStr(1, .Offset(, 2).NumberFormat, "%") Then

--
Regards,
Tom Ogilvy


Todd Huttenstine wrote in message
...
I have Range O2:O100 and P2:R100. The below code
currently looks in Range P2:P100 and if it finds a % in
the value,
will offset into the corresponding cell in Range O2:O100
and will put the % character in the cell itself.

Instead of the code only looking in Range P2:P100 for a %
in the value, I would like for the code to look in the
range expanded to P2:R100 for a % in the value.


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





All times are GMT +1. The time now is 01:01 PM.

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