I have this set of code and it's saying I have a global var error and if by chance you have a way to make this code any less complicated that would also be appreciated.
Code:
Sub test_if_statemnts()
'
' test_if_statemnts Macro
'
'
keybox1 = ThisWorkbook.Sheets("contact").Range("B5")
keybox2 = ThisWorkbook.Sheets("contact").Range("B10")
keybox3 = ThisWorkbook.Sheets("contact").Range("B15")
keybox4 = ThisWorkbook.Sheets("contact").Range("B20")
keybox5 = ThisWorkbook.Sheets("contact").Range("B25")
keybox6 = ThisWorkbook.Sheets("contact").Range("B30")
keybox7 = ThisWorkbook.Sheets("contact").Range("B35")
keybox8 = ThisWorkbook.Sheets("contact").Range("B40")
keybox9 = ThisWorkbook.Sheets("contact").Range("B45")
keybox10 = ThisWorkbook.Sheets("contact").Range("B50")
If [F1] = keybox1 Then
Copy ("A5")
ElseIf [F8] = keybox2 Then
Copy ("A10")
ElseIf [F8] = keybox3 Then
Copy ("A15")
ElseIf [F8] = keybox4 Then
Copy ("A20")
ElseIf [F8] = keybox5 Then
Copy ("A25")
ElseIf [F8] = keybox6 Then
Copy ("30")
ElseIf [F8] = keybox7 Then
Copy ("35")
ElseIf [F8] = keybox8 Then
Copy ("40")
ElseIf [F8] = keybox9 Then
Copy ("45")
ElseIf [F8] = keybox10 Then
Copy ("50")
End If
End Sub
Function Copy(x As String) As String
y = where(x)
End Function
Function where(x As String) As String
Sheets("contact").Select
ActiveSheet.Range("x").Select <-----------------------------------------------------------------------
Selection.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
End Function