Godders199
Active Member
- Joined
- Mar 2, 2017
- Messages
- 313
- Office Version
- 2013
Hello, i have the following code for a command button, however currently whenever i select a name via the message box the sheet name changes to that name
I cannot see anything in my code to do this... Can only think i have pressed or selected something in error. just cant find it.
Any ideas why the tab name changes?
Private Sub CommandButton1_Click()
DimproductRow As Long
Dim productNameAs String
Name =InputBox("What is Advisers name?")
On Error GoToerrNotFound
agentRow =Sheets("Advisers").Range("c:c").Find(What:=Name).row
On Error GoTo 0
MsgBoxSheets("Advisers").Range("C1").Value & " - "& Sheets("Advisers").Range("C" & agentRow).Value& vbNewLine & _
Sheets("Advisers").Range("A1").Value& " - " & Sheets("Advisers").Range("A"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("B1").Value& " - " & Sheets("Advisers").Range("B"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("C1").Value & " -" & Sheets("Advisers").Range("C" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("d1").Value& " - " & Sheets("Advisers").Range("D"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("f1").Value & " -" & Sheets("Advisers").Range("f" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("aa1").Value & " -" & Sheets("Advisers").Range("aa" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("h1").Value& " - " & Sheets("Advisers").Range("h"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("m1").Value& " - " & Sheets("Advisers").Range("m"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("i1").Value& " - " & Sheets("Advisers").Range("i"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("j1").Value& " - " & Sheets("Advisers").Range("j"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("k1").Value& " - " & Sheets("Advisers").Range("k"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("ac1").Value& " - " & Sheets("Advisers").Range("ac"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("ae1").Value& " - " & Sheets("Advisers").Range("ae"& agentRow).Value
Exit Sub
errNotFound:
MsgBox"Adviser name not found, has to be the same as in Hierarchy!",vbCritical
End Sub
I cannot see anything in my code to do this... Can only think i have pressed or selected something in error. just cant find it.
Any ideas why the tab name changes?
Private Sub CommandButton1_Click()
DimproductRow As Long
Dim productNameAs String
Name =InputBox("What is Advisers name?")
On Error GoToerrNotFound
agentRow =Sheets("Advisers").Range("c:c").Find(What:=Name).row
On Error GoTo 0
MsgBoxSheets("Advisers").Range("C1").Value & " - "& Sheets("Advisers").Range("C" & agentRow).Value& vbNewLine & _
Sheets("Advisers").Range("A1").Value& " - " & Sheets("Advisers").Range("A"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("B1").Value& " - " & Sheets("Advisers").Range("B"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("C1").Value & " -" & Sheets("Advisers").Range("C" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("d1").Value& " - " & Sheets("Advisers").Range("D"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("f1").Value & " -" & Sheets("Advisers").Range("f" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("aa1").Value & " -" & Sheets("Advisers").Range("aa" &agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("h1").Value& " - " & Sheets("Advisers").Range("h"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("m1").Value& " - " & Sheets("Advisers").Range("m"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("i1").Value& " - " & Sheets("Advisers").Range("i"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("j1").Value& " - " & Sheets("Advisers").Range("j"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("k1").Value& " - " & Sheets("Advisers").Range("k"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("ac1").Value& " - " & Sheets("Advisers").Range("ac"& agentRow).Value & vbNewLine & _
Sheets("Advisers").Range("ae1").Value& " - " & Sheets("Advisers").Range("ae"& agentRow).Value
Exit Sub
errNotFound:
MsgBox"Adviser name not found, has to be the same as in Hierarchy!",vbCritical
End Sub