Hello all,
Is there any way to simplify this given macro? I am changing name for 5 headers, in the future, I may have the need to change 1000.
Thanks for your time guys.
Is there any way to simplify this given macro? I am changing name for 5 headers, in the future, I may have the need to change 1000.
Code:
Sub RenamePServer()
Application.DisplayAlerts = False
Dim Found1, Found2, Found3, Found4, Found5
Set Found1 = Rows(1).Find(what:="Juridiction Code", LookIn:=xlValues, lookat:=xlWhole)
Set Found2 = Rows(1).Find(what:="Juridiction Code Text", LookIn:=xlValues, lookat:=xlWhole)
Set Found3 = Rows(1).Find(what:="GRN/SE No", LookIn:=xlValues, lookat:=xlWhole)
Set Found4 = Rows(1).Find(what:="GRN/SE Dt", LookIn:=xlValues, lookat:=xlWhole)
Set Found5 = Rows(1).Find(what:="GRN/SE Yr", LookIn:=xlValues, lookat:=xlWhole)
If Found1 Is Nothing Then
MsgBox ("Juridiction Code Missing")
GoTo Code1
Else:
Found1.Value = "Business Place"
End If
Code1:
If Found2 Is Nothing Then
MsgBox ("Juridiction Code text Missing")
GoTo Code2
Else:
Found2.Value = "Business Place Des"
End If
Code2:
If Found3 Is Nothing Then
MsgBox ("GRN/SE No Missing")
GoTo Code3
Else:
Found3.Value = "GRN Number"
End If
Code3:
If Found4 Is Nothing Then
MsgBox ("GRN/SE Dt Missing")
GoTo Code4
Else:
Found4.Value = "GRN Date"
End If
Code4:
If Found5 Is Nothing Then
MsgBox ("GRN/SE Yr Missing")
Exit Sub
Else:
Found5.Value = "GRN Year"
End If
End Sub
Thanks for your time guys.