I have a macro that changes the font color and font size of a cell. It is located in a module that contains several other macros. If I declare Option Explicit in that module, the macro will not run. I get an "compile error" message stating that the variable "font_size" is is not defined. If I remove Option Explicit, the macro runs, but my limited experience with VBA macros tells me that this isn't right, that I should fix the code so that it will run with Option Explicit declared. The problem is, I don't know how to fix it. Can anyone help me. Here is the code:
I'm stumped!
Code:
Sub BlackToRed()
Dim font_colour As Integer
Dim B As Variant
font_colour = 1
font_size = 10
ActiveSheet.Unprotect Password:="myPWD"
ActiveCell.Font.ColorIndex = font_colour
ActiveCell.Font.Size = font_size
If font_colour = 1 Then
font_colour = 3
End If
If font_size = 10 Then
font_size = 11
End If
Selection.Font.ColorIndex = font_colour
ActiveCell.Font.Size = font_size
ActiveSheet.Protect Password:="myPWD"
End Sub