I have the following code and want to make it run whenever any of the ranges change (specifically T5, T9, T13). I've tried multiple ways but none seem to work. The code works fine when I step through it but when I call it, it doesn't run (Refer to Below).
In addition to the above I have the following:
This should call the above Macro to run, tell me it's completed, then print. It's just giving me the message box I click ok and it prints but none of the ranges are updated like when I step through it manually.
Code:
Sub BoldPartText1()Dim Part1Len, Part2Len, DividerLen As Integer
Dim Divider As String
Part1Len = Len(Range("T1"))
Part2Len = Len(Range("T3"))
Part3Len = Len(Range("T5"))
Part4Len = Len(Range("T7"))
Part5Len = Len(Range("T9"))
Part6Len = Len(Range("T11"))
Part7Len = Len(Range("T13"))
Part8Len = Len(Range("T15"))
Part9Len = Len(Range("T17"))
Divider = " "
DividerLen = Len(Divider)
Range("D25:N26").UnMerge
Range("D25").Clear
Range("D25") = Range("T1") & Divider & Range("T3") & Divider & Range("T5") & Divider & Range("T7") & Divider & Range("T9") & Divider & Divider & Range("T11") & Divider & Range("T13") & Divider & Range("T15") & Divider & Range("T17")
With Range("D25").Characters(Start:=1, Length:=Part1Len).Font
.FontStyle = "Bold"
End With
With Range("D25").Characters(Start:=Part1Len + 2 + Part2Len + 1, Length:=Part3Len).Font
.FontStyle = "Bold"
End With
With Range("D25").Characters(Start:=Part1Len + 2 + Part2Len + 1 + Part3Len + 1 + Part4Len + 1, Length:=Part5Len).Font
.FontStyle = "Bold"
End With
With Range("D25").Characters(Start:=Part1Len + 2 + Part2Len + 1 + Part3Len + 1 + Part4Len + 1 + Part5Len + 2 + Part6Len + 1, Length:=Part7Len).Font
.FontStyle = "Bold"
End With
With Range("D25").Characters(Start:=Part1Len + 2 + Part2Len + 1 + Part3Len + 1 + Part4Len + 1 + Part5Len + 2 + Part6Len + 1 + Part7Len + 1, Length:=Part8Len).Font
.FontStyle = "Bold"
End With
Range("D25:N26").Merge
Range("D25").WrapText = True
End Sub
In addition to the above I have the following:
Code:
Sub Print_Hidden() ActiveWorkbook.Unprotect "1"
Call BoldPartText1
MsgBox "Complete"
Application.ScreenUpdating = False
With Sheets("Print")
.Visible = True
.PrintOut Copies:=1, Collate:=True
.Visible = False
End With
Application.ScreenUpdating = True
ActiveWorkbook.Protect "1"
End Sub
This should call the above Macro to run, tell me it's completed, then print. It's just giving me the message box I click ok and it prints but none of the ranges are updated like when I step through it manually.