Format cell in column B based on value in the next cell (column c)

G

Guest

I did a basic select all from one application & pasted it into Excel
(starting a cell A1).
How do I conditionally format Column C based on the value in Column B?

What I'm looking for is:
If the row value in Column B = 1, then ident the Column C 1 time.
If the row value in Column B = 2, then ident the Column C 2 times.
etc.

To make things worse:
the range of data keeps changing (it may be 200 rows one week & 800 rows the
next).
 
J

JulieD

Hi Nicole

AFAIK you'll have to use a macro for this as conditional formatting does not
allow for indents. Is a macro solution acceptable?

Cheers
JulieD
 
G

Guest

Yes - I macro is an acceptable solution. I just need a little help and
sample....PLEASE!
 
J

JulieD

Hi Nicole

here's some sample code, it requires you to choose column C and then run the
macro
---
Sub indentdata()

For Each cell In Selection
on error resume next
cell.InsertIndent cell.Offset(0, -1).Value
Next

End Sub
---

to use the code, right mouse click on a worksheet tab and choose view code
in the VBE window choose insert / module
copy & paste the code on the right hand of the screen
use alt & f11 to get back to your workbook
select column C
choose tools / macro / macros
find the indentdata macro
click run

Hope this helps
Cheers
JulieD
 
G

Guest

You are AWESOME!!! THANKS SO MUCH.
I didn't think it would be that easy. Thanks again

Cheers back at you!
Nicole
 
J

JulieD

you're welcome and thanks for the feedback

Nicole said:
You are AWESOME!!! THANKS SO MUCH.
I didn't think it would be that easy. Thanks again

Cheers back at you!
Nicole
 
G

Guest

OK. How about this one. I want to conditionally format one cell or a range
of cells based on the condition or value in a totally different cell or range
of cells. How would I do that? Like color fill cell C2 yellow if cell H20
equals Y. And macros are OK. I just don't know the terms or commands I
would use to program that stuff.

Thanks to anyone that can help.
 
G

Gord Dibben

Leon

You can use Conditional Formatting to achieve this.

e.g. select C2 and Format>CF>Formula is: =H20="Y"

Select Yellow from the Format>Patterns and OK your way out.

Enter Y in H20 and watch C2 turn yellow.


Gord Dibben Excel MVP
 

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

Top