Results 1 to 4 of 4

Please help with VBA - Conditional Formatting from 2 columns

Threaded View

  1. #1
    Registered User
    Join Date
    11-16-2015
    Location
    Baltimore MD
    MS-Off Ver
    365
    Posts
    28

    Please help with VBA - Conditional Formatting from 2 columns

    Thank you for reading my post. I have a spreadsheet that contains a table (Table2) with 10K + rows. Column D is labeled "Master Name." Column E is labeled "Child Name???" I have a VBA that colors the row Gray when a P is in the "Master Name" column. I need to add another Conditional Format that would Bold all of the text in a row where a "c" is in Column E "Child Name???" column. These conditions are not dependant upon each other with the exception that if Column D has a "P", Column E can not have a "c." If a row does not have a "P" or a "c" if should not have any color or bold.

    I can't use a regular Conditional Format because it slows my worksheet considerably.


    The complete VBA is below - The portion of with the existing Condiitonal VBA is at the bottom. The existing VBA is attached to a command button. The sample worksheet is attached.

    I really appreciate your help. I am not very savvy with VBA so I appreciate your patience.



    Private Sub CommandButton1_Click()
    
        Dim myActiveCell  As Range
        Set myActiveCell = Selection
    
        myActiveCell.AddComment "StartCell"
        
        
        Range("Table2[[#Headers],[Order]]").Select
        Range(Selection, Selection.End(xlToRight)).Select
        Range(Selection, Selection.End(xlDown)).Select
        ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Clear
        ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add2 _
            Key:=Range("Table2[Master Account Number]"), SortOn:=xlSortOnValues, Order _
            :=xlAscending, DataOption:=xlSortNormal
        ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort.SortFields.Add2 _
            Key:=Range("Table2[Master order]"), SortOn:=xlSortOnValues, Order:= _
            xlAscending, DataOption:=xlSortNormal
        With ActiveWorkbook.Worksheets("Sheet1").ListObjects("Table2").Sort
            .Header = xlYes
            .MatchCase = False
            .Orientation = xlTopToBottom
            .SortMethod = xlPinYin
            .Apply
        End With
        
        Cells.Find(What:="StartCell", After:=Range("A1"), LookIn:=xlComments, _
            LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
            MatchCase:=False, SearchFormat:=False).Activate
    
        Selection.ClearComments
        
    Dim LastRow As Long, c As Range
    Dim MyRange As Range
    LastRow = Cells(Cells.Rows.Count, "D").End(xlUp).Row
    Set MyRange = Range("D1:D" & LastRow)
    For Each c In MyRange
    If UCase(Trim(c.Value)) = "P" Then
        c.Offset(, -3).Resize(, 14).Interior.Color = RGB(231, 230, 230)
    Else
        c.EntireRow.Interior.Color = xlNone
    End If
    Next
    End Sub
    Attached Files Attached Files
    Last edited by Baltimorejack68; 10-13-2020 at 05:51 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] conditional formatting - different columns
    By NestorHenao in forum Excel General
    Replies: 2
    Last Post: 03-20-2019, 10:10 AM
  2. Replies: 5
    Last Post: 03-13-2019, 08:04 PM
  3. [SOLVED] Conditional Formatting Between Two Columns
    By chergian in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 03-29-2017, 02:37 AM
  4. Conditional Formatting two columns
    By May10 in forum Excel General
    Replies: 1
    Last Post: 01-09-2014, 09:00 PM
  5. Conditional formatting two columns
    By Bupitz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-13-2013, 03:54 PM
  6. Conditional Formatting 2 Columns
    By Nunzii in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2011, 12:58 PM
  7. conditional formatting for 3 columns (?)
    By eighcoop in forum Excel General
    Replies: 3
    Last Post: 01-06-2010, 08:02 PM

Tags for this Thread

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