Functions not visible

Fibo

New Member
Joined
Oct 22, 2023
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello,
In the event Workbook_Open() from ThisWorkBook I am calling several functions.
During the opening of the workbook excel didn't execute anything from Workbook_Open().
Even the msgbox didn't pop.
I was told to place all the functions that I call in this procedure within ThisWorkBook.
For example I moved the function ColorInit(0, "") from a module just after "Private Sub Workbook_Open()" as you can see below.
Upon opening everything works now. Thats great.

However,
The problem has changed side.
My other calls of these functions don't see them.
For Example Call ColorInit (... is unkwown in the rest of my code. I can't use it, it is not defeined.
Does any one have an idea to fix this?

Rich (BB code):
Private Sub Workbook_Open()
Dim F As String, GGDriveSavePath As String, TempStr As String
Dim TempTbl As Variant
Dim BkupFileTbl() As String
Dim FileDateTbl() As Date
ReDim BkupFileTbl(1 To 1000)
ReDim FileDateTbl(1 To 1000)

Msgbox  "Open is executing"
Version = "Zanzibar operation V3.8 December 1st, 2023"
Call ColorInit(0, "")
....
End Sub

Function ColorInit(ColorNb As Long, ColorName As String) As Variant
Dim T As Long
ReDim ColorList(1 To 30, 1 To 2)
...
 
Last edited by a moderator:

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
If you didn't even see the message box before, then the two problems were probably not related. Which module were the functions in before? If it was just a normal module, not marked private, then they should stay there.
 
Upvote 0
The Functions were in a Module and named like this:

VBA Code:
Function ColorInit(ColorNb As Long, ColorName As String) As Variant
Dim T As Long
ReDim ColorList(1 To 25, 1 To 2)

'Pink
ColorList(1, 1) = "Pink": ColorList(1, 2) = 14786555: Pink = 14786555
...
End Function

I just placed it back in the module and if I remove the ' before Call ColorInit it doesn't go in.

VBA Code:
Private Sub Workbook_Open()

'Call ColorInit(0, "")
'ThisWorkbook.Worksheets("Main").Range("G3") = ColorList(2, 2)

On Error Resume Next
MsgBox ("Before Hide")
...

End Sub

It is even worst as my project doesn't open.
It shows the sheets and if I click anywhere, excel disappears.
 
Last edited by a moderator:
Upvote 0
Which module was it in?

Also, do you have conditional formatting that uses functions written in VBA?
 
Upvote 0
I have conditional formating on a few sheets.
The conditional formating rules are created in vba upon activation of the sheets.
These sheets are not touched during the opening process.
 
Upvote 0
Again, which module was the code in?

Do any of the rules actually use functions written in code (UDFs)?
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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