Results 1 to 4 of 4

Comparing text strings

Threaded View

  1. #1
    Registered User
    Join Date
    11-22-2011
    Location
    Noida
    MS-Off Ver
    Microsoft 365 MSO (16.0.13......) 32 bit
    Posts
    40

    Question Comparing text strings

    I have to do a simple operation from macro that it compares text in three columns and gives results using following logic in adjacent column :-

    Column --> G H I ---> J
    FC FC FC ---> FC
    NC NC NC ---> NC
    Else

    result in J should be PC.

    Also, if F = FC, color cell with Green, If F=NC, color cell Red and else if its PC color cell Blue.
    I tried to write a code and but while compilation it shows some error. I think there is some error in the code lines where I have applied "And" operation.
    Could any one help me in correcting the code.

    Thanks is advance !!

    LastRow = Range("A" & Rows.Count).End(xlUp).Row
        For RowNo = 2 To LastRow
            If Cells(RowNo, "G") And Cells(RowNo, "H") And Cells(RowNo, "I") = "FC" Then
                strCompliance = "FC"
            ElseIf Cells(RowNo, "G") And Cells(RowNo, "H") And Cells(RowNo, "I") = "NC" Then
                strCompliance = "NC"
            Else
                strCompliance = "PC"
            End If
            
            With Cells(RowNo, "J")
                .Value = strCompliance
                .Font.Bold = True
                If Cells(RowNo, "J") = "FC" Then
                Cells(RowNo, "J").Interior.Color = RGB(0, 255, 0)
                ElseIf Cells(RowNo, "J") = "NC" Then
                Cells(RowNo, "J").Interior.Color = RGB(255, 0, 0)
                ElseIf Cells(RowNo, "J") = "PC" Then
                Cells(RowNo, "J").Interior.Color = RGB(0, 0, 255)
                End If
            End With
    Last edited by gmalpani; 12-19-2011 at 05:58 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1