The Font Size and the HorizontalAlignment of Text in various rows will have to be different.
So, when the programme moves from one Row to the other I am trying to pass to a Subroutine the Font Size whether 10 or 11 and the Alignment property whether xlCenter or xlLeft.
I select a range and I call the Subroutine.
This is the Subroutine that is called:
When the Subroutine is simply "Private Sub TxtTunerTwoOff" and when I use "Call TxtTunerTwoOff'" to run the Subroutine, then the code ".Offset(0, 4).HorizontalAlignment = xlCenter" works fine.
But when the Subroutine is "Private Sub TxtTunerTwoOff(FontSiz As Integer, Alignr As String)", then the code ".Offset(0, 4).HorizontalAlignment = Alignr" gets the following error message:
Run-time error '1004':
Unable to set the HorizontalAlignment property of the Range class
Any suggestion is appreciated.
So, when the programme moves from one Row to the other I am trying to pass to a Subroutine the Font Size whether 10 or 11 and the Alignment property whether xlCenter or xlLeft.
I select a range and I call the Subroutine.
Code:
Range("B1").Select
Call TxtTunerTwoOff(11, "xlleft")
Code:
Private Sub TxtTunerTwoOff(FontSiz As Integer, Alignr As String)
With Selection
.Offset(0, 4).Font.Bold = True
'.Offset(0, 4).Font.Size = 11
.Offset(0, 4).Font.Size = FontSiz
'.Offset(0, 4).HorizontalAlignment = xlCenter
.Offset(0, 4).HorizontalAlignment = Alignr
End With
End Sub
But when the Subroutine is "Private Sub TxtTunerTwoOff(FontSiz As Integer, Alignr As String)", then the code ".Offset(0, 4).HorizontalAlignment = Alignr" gets the following error message:
Run-time error '1004':
Unable to set the HorizontalAlignment property of the Range class
Any suggestion is appreciated.
Last edited: