VBA (?) How to increase text size for an entire row, based on 1 cell's content - conditional formatting

bmcley

New Member
Joined
Aug 26, 2015
Messages
4
Hello, and thanks in advance for the help.

Using Excel 2010 on a Windows 7 machine.

I have a list of about 4000 items (products). I want my salespeople to be able to run through the list and quickly identify which items are being purchased by a customer.

I have already created the formula to show whether an item is an "A","B","C", or "D" item. This is populated by a VLOOKUP statement in column G.

Essentially I want to shrink the text very small (say 8) to maximize page space, but if column G shows an A, B, or C, I want that entire row to jump to a larger size of text (say 16). Arial or Calibri is fine.

I have them conditionally formatted to highlight, but that not really doing what I need.

Again, thanks in advance for your help.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How about this?

Code:
Option Explicit
Option Compare Text


Sub fSize()
Dim r   As Range
Dim cel As Range

Set r = Range("G1", Range("G" & Rows.Count).End(xlUp))

    For Each cel In r
        With cel
            Select Case cel
                Case "A"
                    .Font.Size = 16
                Case "B"
                    .Font.Size = 16
                Case "C"
                    .Font.Size = 16
                Case "D"
                    .Font.Size = 16
                Case Else
                    .Font.Size = 8
            End Select
        End With
    Next cel
    
         
End Sub
 
Upvote 0
Of course to speed things up you can add

Code:
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

at the beginning of the code and

Code:
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

at the end.
 
Upvote 0
This version works as well and is a lot faster than the previous.

Tested on ~60,000 rows, the first code took 9 seconds to complete whereas the following code took 1 second.

Code:
Sub test2()
Dim r   As Range
Dim cel As Range
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set r = Range("G2", Range("G" & Rows.Count).End(xlUp))

r.Font.Size = 8

r.AutoFilter Field:=1, Criteria1:="a", Operator:=xlOr, Criteria2:="b"
r.SpecialCells(xlCellTypeVisible).Font.Size = 16
r.AutoFilter Field:=1, Criteria1:="c", Operator:=xlOr, Criteria2:="d"
r.SpecialCells(xlCellTypeVisible).Font.Size = 16
r.AutoFilter

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
 
Upvote 0
Irobbo, that's awesome. Thank you sir. And thanks for the quick response.

One other question though, this is enlarging the size of the text for that column. Is there a way to enlarge the text of the entire row, or more specifically, columns A-H of that line?

Thanks again.
 
Upvote 0
Yes,

We're back to the slower version, but it should work.

Code:
Sub fSize()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

Dim r   As Range
Dim cel As Range

Set r = Range("G1", Range("G" & Rows.Count).End(xlUp))

    For Each cel In r
        With cel.Offset(, -6).Resize(1, 8)
            Select Case cel
                Case "A"
                    .Font.Size = 16
                Case "B"
                    .Font.Size = 16
                Case "C"
                    .Font.Size = 16
                Case "D"
                    .Font.Size = 16
                Case Else
                    .Font.Size = 8
            End Select
        End With
    Next cel
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic

End Sub
 
Upvote 0
Good morning lrobbo314,

Can you please help me take the above code and expand it to increase the size of text in the entire row, if I have an "A,B, or C" in either row G or row J.
It is currently working great for row G, but I have added another customer to the data, so that I can compare the two. I attempted to figure this out myself, but got some wonky results, where the entire row is not necessarily increase text size.

Thanks in advance for your help.
 
Upvote 0

Forum statistics

Threads
1,217,358
Messages
6,136,094
Members
449,991
Latest member
IslandofBDA

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top