Compile Error: Expected: Identifier

JLeech1992

New Member
Joined
Nov 22, 2022
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

I am new to VBA coding, I don't fully understand some aspects of coding and I'm still learning so please bare with me on this, I am in the middle of making an inventory control workbook with Microsoft Excel to manage my works returns inventory and workload. I'm currently trying to create buttons to hide and unhide sheets to impersonate actual buttons, keep my workbook tidy and just have my Dashboard visible on start up.

On the Dashboard I have the following buttons to apply macros:
- Inventory (In this sheet I will also have 3 buttons needing Macros, Aisle G Inventory, Aisle H Inventory and Inbound Inventory)
- Pending Area
- Testing Overview
- Product Catalogue
- FSE Index
- Branch Index
- Collections
- Meeting Queries
(Every sheet will have a back button to direct me back to the dashboard with all the sheets hidden)

What i wanted to happen previously: (The code I've been trying to solve)
- Click 'Pending Area" button = Unhides 'Pending Area' - instantly directs me to 'Inventory'
- Click 'Back' button = Hides 'Pending Area' - instantly directs me to 'Dashboard'

What i want to happen now: (The previous code but updated and now trying to achieve)
- Click 'Pending Area" button = Unhides 'Pending Area' - instantly directs me to 'Pending Area' - Hides 'Dashboard'
- Click 'Back' button = Unhides 'Dashboard' - instantly directs me to 'Dashboard' - Hides 'Pending Area'
(I want this to happen with each sheet individually)


I have done some online research in regards of doing this and found some threads and youtube video tutorials, which has kind of helped but I'm at a standstill due to a 'Compile Error: Expected: Identifier'.
I have followed someone's instructions via a youtube video tutorial and i consistently come to this error (Even though it was working perfectly fine on the tutorial video). I have done research on this error also, during this i found out that it indicates multiple reasons why I receive this error and I cant seem to find/understand where I have gone wrong in the coding or cross reference my coding to the similar issues stated in threads.

My coding what i wanted to happen previously is:

Option Explicit

Sub ViewPendingArea()

Sheets("Pending Area").Visible = True
Sheets("Pending Area").Select

End Sub

Sub HidePendingArea()

Sheets("Pending Area").Visible = False

End Sub

The coding what i want to happen now is:

I haven't created this yet due to the error I'm receiving with my previous coding, I want to understand where i have went wrong with my previous coding before I update it to my new one. *What i want to happen now is stated above*

Compile Error: Expected: Identifier indications:

I understand that when I receive this error, the debugger will appear and highlight the issue in yellow.

Here is what i receive:

Option Explicit

> Sub ViewPendingArea()

Sheets("Pending Area").Visible = True
Sheets("Pending Area").Select

End Sub

Sub HidePendingArea()

Sheets("Pending Area").Visible = False

End Sub



Keep in mind that I am still learning how to use VBA and some aspects i don't fully understand so i may not understand everything you explain, so please try and simplify your replies.
I would like someone with professional experience to advise me, Any advice or guidelines will be much appreciated. thank you.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Remove the > at the start of that line.
 
Upvote 0
Remove the > at the start of that line.
Hi RoryA,

That isn't part of the code, whilst debugging and the issue is highlighted there is a yellow arrow next to it. I used '>' as an arrow as i couldn't insert an arrow in this thread.
 
Upvote 0
That's odd because there is nothing wrong with that code per se - I can copy and paste it into a module and run it without error.

Can you run it from the VB editor by clicking somewhere in the code and pressing f5?
 
Upvote 0
I have just tried what you have advised, the same result occurs. "Compile Error: Expected: Identifier"

also a window opens with:

Private Sub

End Sub
 
Upvote 0
Delete that code as it is invalid.
 
Upvote 0
I mean delete this:

Code:
Private Sub

End Sub

That is not valid code.
 
Upvote 0
I mean delete this:

Code:
Private Sub

End Sub

That is not valid code.
My apologies for the late reply, workload has been a nightmare. Yeah I have deleted that code but I have came across more information on this error. I have right clicked on the issue that is highlighted in yellow and went to 'definition' which gives me this 'Identifier under cursor is not recognized'. What is your advice moving forward with this?
 
Upvote 0
I think I'd probably have to see the workbook. There is nothing wrong with the code that you posted, so there must be something else in the workbook causing the issue.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top