nicholasmarella
New Member
- Joined
- Feb 10, 2020
- Messages
- 5
- Office Version
- 2019
- Platform
- Windows
Hello,
I will try to explain this as best as possible without attaching pictures (forum says "not a picture" at the top - even so, each time I screen shot, it comes out extremely blurry so it's essentially useless regardless). I have a group of cells merged together (G11 through I17) that uses a formula to either return a 0 through 11 (numerical) result or a "SOP Error" result. When the numerical value shows, the font is 24 which is exactly what I need. When the SOP Error value shows, it remains 24 and I need it to change to 12 to fit properly. The numerical value comes back based on a series of check boxes being checked. The SOP error comes back and essentially overrides the numerical value when a specific check box, separate from the others related to the numerical value, is checked.
I need a macro that will automatically changed the font size to 12 when the SOP Error value is returned but remains at 12 for any other value. I've tried googling and copying and pasting various macro codes I've found online but nothing seems to work. I'm not sure if I'm just doing something wrong when it comes to pasting the code and expecting it to begin working by itself, or if there's something wrong with the codes I'm finding online. Any help would be greatly appreciated!
A few codes I've tried online;
Private Sub Worksheet_Calculate()
Dim rng As Range
Dim rCell As Range
Set rng = Range("A1:A10")
For Each rCell In rng
If Len(rCell.Text) > 2 Or _
Val(rCell.Value) > 10 Then
rCell.Font.Name = "Arial"
rCell.Font.Size = 16
Else
rCell.Font.Name = "Times New Roman"
rCell.Font.Size = 12
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
If Union(Target, Range("A1:A10")).Address = _
Range("A1:A10").Address Then
Application.EnableEvents = False
For Each rCell In Target
If Len(rCell.Text) > 2 Or _
Val(rCell.Value) > 10 Then
rCell.Font.Name = "Arial"
rCell.Font.Size = 16
Else
rCell.Font.Name = "Times New Roman"
rCell.Font.Size = 12
End If
Next
Application.EnableEvents = True
End If
End Sub
FYI, I'm not the most familiar with macros and the lingo as well. With that said, I may need any responses broken down into something I can easily understand lol.
Also, if there's any more information I'm supposed to put in this thread, please let me know.
I will try to explain this as best as possible without attaching pictures (forum says "not a picture" at the top - even so, each time I screen shot, it comes out extremely blurry so it's essentially useless regardless). I have a group of cells merged together (G11 through I17) that uses a formula to either return a 0 through 11 (numerical) result or a "SOP Error" result. When the numerical value shows, the font is 24 which is exactly what I need. When the SOP Error value shows, it remains 24 and I need it to change to 12 to fit properly. The numerical value comes back based on a series of check boxes being checked. The SOP error comes back and essentially overrides the numerical value when a specific check box, separate from the others related to the numerical value, is checked.
I need a macro that will automatically changed the font size to 12 when the SOP Error value is returned but remains at 12 for any other value. I've tried googling and copying and pasting various macro codes I've found online but nothing seems to work. I'm not sure if I'm just doing something wrong when it comes to pasting the code and expecting it to begin working by itself, or if there's something wrong with the codes I'm finding online. Any help would be greatly appreciated!
A few codes I've tried online;
Private Sub Worksheet_Calculate()
Dim rng As Range
Dim rCell As Range
Set rng = Range("A1:A10")
For Each rCell In rng
If Len(rCell.Text) > 2 Or _
Val(rCell.Value) > 10 Then
rCell.Font.Name = "Arial"
rCell.Font.Size = 16
Else
rCell.Font.Name = "Times New Roman"
rCell.Font.Size = 12
End If
Next
End Sub
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rCell As Range
If Union(Target, Range("A1:A10")).Address = _
Range("A1:A10").Address Then
Application.EnableEvents = False
For Each rCell In Target
If Len(rCell.Text) > 2 Or _
Val(rCell.Value) > 10 Then
rCell.Font.Name = "Arial"
rCell.Font.Size = 16
Else
rCell.Font.Name = "Times New Roman"
rCell.Font.Size = 12
End If
Next
Application.EnableEvents = True
End If
End Sub
FYI, I'm not the most familiar with macros and the lingo as well. With that said, I may need any responses broken down into something I can easily understand lol.
Also, if there's any more information I'm supposed to put in this thread, please let me know.