If in Column color

amerifax

Registered User.
Local time
Today, 08:28
Joined
Apr 9, 2007
Messages
304
I have to items I'm trying to accomplish.

1. I have two columns. I have names in colum a and b. If column "A" has a name that is not in column "B", I would like that name added to the bottom of column "B" colored in "Red".

2. For all names that are in column "B" and not in column "A" I would like them to be Colored "Blue".

Thanks for the help.

Bob
 
This is not the best code but it will get you started dealing with whats in column A but not in column B. It will be easy to modify to work for whats in column B but not in column A. I've built the code using seperate macros as I thought it would be easier. The first sub routine you will need to run is movenext, this will then call the others as required. hope it is of help
smiler44



Code:
Dim contents As String ' contents of cell
Dim curcell As String ' current cell
 
Sub movenext()
Range("A1").Select
Selection.Copy
contents = Range("A1").Text
Do Until contents = ""
curcell = ActiveCell.Address
Selection.Copy
contents = ActiveCell.Text
Call Macro1
ActiveCell.Offset(1, 0).Activate ' down
Loop
MsgBox ("last row checked")
End Sub
 
Sub Macro1()
On Error GoTo errorhandler
    Columns("B:B").Select
    Selection.Find(What:=contents, After:=ActiveCell, LookIn:=xlFormulas, Lookat _
        :=xlPart, searchorder:=xlByRows, searchdirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate
        Range(curcell).Select
        
errorhandler:
Select Case Err
        Case 91
        Call findlastrow
      Resume Next
        End Select
End Sub
 
Sub findlastrow()
  
    Dim c As Object
    ' c.row is the number of the last row
    Dim target As String
    Dim num As String
    num = 1
    With Sheets("Sheet1").Range("b:b")
     Set c = .Find(What:="*", LookIn:=xlValues, Lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious)
    End With
    
    target = c.Row + num ' helps to move to next free ro in column B
    Range("B" & target).Select
ActiveSheet.Paste
 With Selection.Font
       ' .Name = "Arial"
       ' .FontStyle = "Regular"
       ' .Size = 10
       ' .Strikethrough = False
       ' .Superscript = False
       ' .Subscript = False
       ' .OutlineFont = False
       ' .Shadow = False
       ' .Underline = xlUnderlineStyleNone
        .ColorIndex = 3  ' makes pasted text red
    End With
  End Sub
 
Back in March of 2010. It wasn't much of a chance for me to understand the code that you help me with. You would think by now I would have a better understanding. I'm really not much closer. But I do appreciate your putting together the code. I wish I had the ability.
Bob
 

Users who are viewing this thread

Back
Top Bottom