Hello, I have a repetitive process that I'd like to try to simplify coding wise. The basics is to take a string from inside module A and send it to Module B and have procedures executed. Example Below:

Private Sub Show_Inputs_Click()

If Show_Inputs.Value = True Then

Dim Last_Row As Integer
Dim Range_Unlock As String

'Find the last non-blank cell in column K
Last_Row = Cells(Rows.Count, 11).End(xlUp).Row

If Last_Row = 4 Then
Range_Unlock = "C4,E4:J4"
Range(Range_Unlock).Select
Selection.Locked = False
Range("$AA$1").Select
ActiveCell.FormulaR1C1 = "Yes"
Range("$C$4").Select
End If

If Last_Row = 5 Then
Range_Unlock = "C4,E4:J4" & ",D5:J5"
Range(Range_Unlock).Select
Selection.Locked = False
Range("$AA$1").Select
ActiveCell.FormulaR1C1 = "Yes"
Range("$C$4").Select
End If

If Last_Row > 5 Then
Range_Unlock = "C4,E4:J" & Last_Row & ",D5:J" & Last_Row
Range(Range_Unlock).Select
Selection.Locked = False
Range("$AA$1").Select
ActiveCell.FormulaR1C1 = "Yes"
Range("$C$4").Select
End If

End Sub


I'd like to change it to something like:

Private Sub Show_Inputs_Click()

If Show_Inputs.Value = True Then

Dim Last_Row As Integer
Dim Range_Unlock As String

'Find the last non-blank cell in column K
Last_Row = Cells(Rows.Count, 11).End(xlUp).Row

If Last_Row = 4 Then
Range_Unlock = "C4,E4:J4"
Call RangeChange (Range_Unlock)
End If

If Last_Row = 5 Then
Range_Unlock = "C4,E4:J4" & ",D5:J5"
Call RangeChange (Range_Unlock)
End If

If Last_Row > 5 Then
Range_Unlock = "C4,E4:J" & Last_Row & ",D5:J" & Last_Row
Call RangeChange (Range_Unlock)
End If

End Sub




Sub RangeChange (Range_Unlock)
Range(Range_Unlock).Select
Selection.Locked = False
Range("$AA$1").Select
ActiveCell.FormulaR1C1 = "Yes"
Range("$C$4").Select
End Sub


How do I pass the Range_Unlock variable from the Sub Show_Inputs_Click to Sub RangeChange?

Thanks!