Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace 2

Status
Not open for further replies.

komark

Technical User
Sep 12, 2005
134
US
Hi,
I have the following Code:

Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Selection.Insert Shift:=xlToRight

Application.ScreenUpdating = False
For x = 1000 To 1 Step -1
If Range("C" & x).Font.Bold Then
Rows(x) = "R"
End If

Next

This code is supposed to shift all the data from Column A to C. Check if anything in Column C is bold. If there is than put an R in cell under Column A. My program is putting R in the entire row. How do i fix this?
Please Help.
 


Hi,
Code:
    For x = 1000 To 1 Step -1
      with Range("C" & x)
        If .Font.Bold Then
            .Value = "R"
        End If
      end with
        
    Next



Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
Replace this:
Rows(x) = "R"
with this:
Cells(x, "A") = "R"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks a lot guys. It works great. But what if i want to color the cell to red? What do i do?
 
No VBA needed for that: have a look at Condtional formatting.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV: Can't it be done by VBA. it would help me if I do it in VBA
 


Why do it in VBA, when there's built-in functionality to do it in Excel via COnditional Formatting as PHV has suggested.


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
I wanted to automate the whole process of post proccessing the data from project in excel. Like changing the date value, cells filling etc. Then I will feed the data into a gantt chart builder.
 


How does using Conditional Formating NOT fit into that approch. It's about as automatic as you can get!


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
Skip,
I guess I am doing the formatting the wrong way.
Under conditional formatting>
condition 1
if cell value is equal to YES
condition 2
cell value is equal to Cell fill RED
 


[tt]
condition 1:
if cell value is equal to YES
FORMAT 1: ???
condition 2:
if cell value is equal to ???
FORMAT 2: fill RED
[/tt]


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
Skip,
If cell value is YES than i wanted to fill another cell the same row: RED. Is this what your conditions doing?
 


It can do that.

Select the column of cells you want to format. Let's assume its f4:f999. Let's assume that the YES's are in column H

in Condition 1:
[tt]
=H4="YES"
[/tt]
Format 1: is red


Skip,

[glasses] [red]Be Advised![/red]
A wee deranged psychic may be runnin' around out there!
SMALL MEDUIM @ LARGE[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top