liamdocherty
New Member
- Joined
- Jan 1, 2019
- Messages
- 8
Hi,
I was wondering how can I open a specific worksheet using VBA code on a command button macro? When then user accesses my "Welcome Sheet" worksheet and clicks on the command button "Students" this should bring them to the "Students" worksheet.
I tried the following code but I got an invalid syntax error message as you can see in this [image.](https://ibb.co/sWGKqRp) Furthermore, some of the code turned to a red code and also one line had a yellow background effect as you can see in this [image.](https://imgur.com/a/JXnMnRf)
Code:
Private Sub CommandButton_2Click()
Sheets("Students").Activate
End Sub
Incase you wanted to check the command button macro is called the same name as written in the code my excel worksheet is linked below. However, I did check and to me it's all correct.
[Video](https://streamable.com/s/984qm/xmsmqv) of me showing I have a worksheet called "Students" and I have correctly set up the command button correctly.
I was wondering how can I open a specific worksheet using VBA code on a command button macro? When then user accesses my "Welcome Sheet" worksheet and clicks on the command button "Students" this should bring them to the "Students" worksheet.
I tried the following code but I got an invalid syntax error message as you can see in this [image.](https://ibb.co/sWGKqRp) Furthermore, some of the code turned to a red code and also one line had a yellow background effect as you can see in this [image.](https://imgur.com/a/JXnMnRf)
Code:
Private Sub CommandButton_2Click()
Sheets("Students").Activate
End Sub
Incase you wanted to check the command button macro is called the same name as written in the code my excel worksheet is linked below. However, I did check and to me it's all correct.
[Video](https://streamable.com/s/984qm/xmsmqv) of me showing I have a worksheet called "Students" and I have correctly set up the command button correctly.