Format

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

Todd Huttenstine

Below is a code that looks in columns P,Q, and R and if it
finds the character "%" will put the value "percent" in
the cell in columnO. I would also like the code to also
look for another condition. That is I want it to look in
the cell in ColumnN and if it finds the value "percent"
anywhere in that cell, will also put the value "percent"
in the cell in columnO.


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"
 
Add:

Or _
InStr(1, .Offset(, -1).NumberFormat, "%")

to your code.
 
That didnt have any affect.
I need for it to search the values in column N which is
offset -1 for "percent". And if it finds this string, to
make the value in cell O say "percent". The values in
columnN can say "Percentage" or "Percentile". Whatever
the case, because the value contains the string "percent"
I need for the code to work.
 
I had to use the code...


If InStr(1, .Offset(, -
1).Value, "Percent") Or _
InStr(1, .Offset(, 1).NumberFormat, "%")
Or _
InStr(1, .Offset(, 2).NumberFormat, "%")
Or _
InStr(1, .Offset(, 3).NumberFormat, "%")
Then
.Value = "percent"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

3 VBA Conditions(last edit) 2
Code Edit 1
Conditional value code 2
Code 2
How to hide password? 1
Format Conditions 3
Macro Trouble with Numbering Sequence 8
Event to add a date if "X" is entered in a cell 3

Back
Top