Consulting

Results 1 to 10 of 10

Thread: Highlight domain

  1. #1

    Highlight domain

    Hi, hope you are doing great
    I need a dyanmic range for active sheet Excel VBA code
    that highlight the email column domain and website column domain if the domains are same it hightlihght the same domain ,if the domains are not same dont hightlight or ignore.
    i also have attached the screenshot .
    I also attached a youtube link i which I explained what I want.https://www.youtube.com/watch?v=xH4o72w-xHw
    Attached Images Attached Images

  2. #2
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,190
    Location
    How about something like the attached?
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  3. #3
    i just want to highlight domain not a entire row

  4. #4
    Excellent work

  5. #5
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,190
    Location
    Maybe the below for just the domain:
    Sub test()
        Dim rCell As Range
        Dim tmp As String
        Dim lStr As String, rStr As String
        
        For Each rCell In Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
            With rCell
                lStr = Left(.Value, InStr(.Value, ".") - 1)
                tmp = Left(.Offset(, 1), InStr(.Offset(, 1), ".") - 1)
                rStr = Right(tmp, Len(tmp) - InStr(tmp, "@"))
                If lStr = rStr Then
                    .Characters(InStr(.Value, lStr), Len(lStr)).Font.ColorIndex = 3
                    .Offset(, 1).Characters(InStr(.Offset(, 1), lStr), Len(lStr)).Font.ColorIndex = 3
                End If
            End With
            tmp = vbNullString
        Next rCell
    End Sub
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  6. #6
    oh it is
    working for me

  7. #7
    I appreciate your work . and your code in working for me ,your work is excellent
    Please make a changings in code,i want to match the domains of Column B(WEBSITE) with column K(Email)
    Please check my screenshot or check my youtube guidance video
    make a changes in code.jpg
    https://www.youtube.com/watch?v=u5N3c2IMt6s

  8. #8
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,054
    Location
    @Kamran AJ. Try making the changes yourself. In your initial example you were using columns A & B right? So when you look at Georgiboy's code what sticks out as defining Column A and Column B?

    Hint 1. Since the below code defines the Range in Column A, what would you consider changing to make it reflect Column B?
    For each rCell in Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row).Cells
    Hint 2. The below code finds the value in Column B of the active row, so what would you change if the column you seek is 9 columns further to the right?
    tmp =Left(.Offset(,1), Instr(.Offset(, 1), ".") -1)
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  9. #9
    Moderator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,190
    Location
    Maybe:
    Sub test()
        Dim rCell As Range
        Dim tmp As String
        Dim lStr As String, rStr As String
        
        For Each rCell In Range("B2:B" & Range("B" & Rows.Count).End(xlUp).Row).Cells
            With rCell
                lStr = Left(.Value, InStr(.Value, ".") - 1)
                tmp = Left(.Offset(, 9), InStr(.Offset(, 9), ".") - 1)
                rStr = Right(tmp, Len(tmp) - InStr(tmp, "@"))
                If lStr = rStr Then
                    .Characters(InStr(.Value, lStr), Len(lStr)).Font.ColorIndex = 3
                    .Offset(, 9).Characters(InStr(.Offset(, 9), lStr), Len(lStr)).Font.ColorIndex = 3
                End If
            End With
            tmp = vbNullString
        Next rCell
    End Sub
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved

    Excel 365, Version 2403, Build 17425.20146

  10. #10
    Thank you so much it is working for me

Posting Permissions

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