VBA - font size for column 1 based on value in column 2

SteamedHams

New Member
Joined
Jun 18, 2018
Messages
3
Hi everyone,

I'm trying to change font size of a cell based on the text of another cell.

For example,
Cell A1 can contain the text "High, Medium, or Low" and cell B1 consists of a dot symbol.
I want the dot symbol in B1 to change font size depending on the value in A1.
Where High = font size 36, Medium = font size 26, and Low = font size 16.

Been trying to figure it out but I am very inexperienced with VBA.

Thanks in advance.
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this:
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 6/18/18 9:20 PM EDT
If Not Intersect(Target, Range("A1")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value = "High" Then Target.Offset(1).Font.Size = 36
If Target.Value = "Medium" Then Target.Offset(1).Font.Size = 26
If Target.Value = "Low" Then Target.Offset(1).Font.Size = 16
End If
End Sub
 
Last edited:
Upvote 0
Thanks for the response. I cannot seem to get it to work. Furthermore, does the code above take into consideration the whole column A or just the single cell? - sorry, I should have been clearer in my description.
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 6/19/18 12:05 PM EDT
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Value = "High" Then Target.Offset(, 1).Font.Size = 36
If Target.Value = "Medium" Then Target.Offset(, 1).Font.Size = 26
If Target.Value = "Low" Then Target.Offset(, 1).Font.Size = 16
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,600
Members
449,038
Latest member
Arbind kumar

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