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.
 
Yeah i was thinking there must be something wrong in the background somewhere that's interfering with the code but unfortunately i wont be able to provide you with my workbook due to working in a security business and this would be against data protection. Would you advise that I make a fresh workbook and start with the coding before i do anything else?
 
Upvote 0

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
You could remove all the data from the workbook first (make sure the error still persists) then post that?
 
Upvote 0
I have permission from my manager to provide you with this workbook without the data. I have kept the macros on and kept the applied macro to the 'Pending Area' button which the error still persists. Is there a way to send you it privately? just for extra security measures.
 
Upvote 0
In the G Aisle | Inventory sheet, you had this:

Code:
Private Sub

End Sub

removing that resolves the errors.
 
Upvote 0
Solution
oh, I never came across that.. much appreciated for your assistance RoryA.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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