Lavina

Board Regular
Joined
Dec 18, 2018
Messages
75
Hey guys,

I'm creating a user form with some buttons, currently i have:

Initialize label with name:

Sub UserForm_Initialize(populatingArray() As Variant, positionOfOverWrite As Integer)
Dim UserForm As Variant
UserForm.Caption = "Data found!"
Call UserFormCaption(populatingArray(), positionOfOverWrite)
End Sub


Caption the rest of the labels:

Sub UserFormCaption(populatingArray() As Variant, positionOfOverWrite As Integer)
LabelOverWriteDescription.Caption = ("Overwriting data at workbook:'" + CStr(populatingArray(positionOfOverWrite, 4)) + "', sheet: '" + CStr(populatingArray(positionOfOverWrite, 5)) + "' cell: row " + CStr(variableInQuestionRow) + ":column " + CStr(variableInQuestionColumn))
CommandButtonOverWriteOne.Caption = "Overwrite this"
CommandButtonOverWriteAll.Caption = "Overwrite all"
CommandButtonOverWriteCancel.Caption = "Cancel"
End Sub



Now when I try to initialize the with a function that carries over the array:

Call UserForm_Initialize(populatingArray(positionOfOverWrite, 4), i)

I get the error that no function or sub defined

Only way i found to open the form:
UserFormOverWrite.Show vbModeless

But with this function i do not move over my array

Why doesn't my module see the subs defined in the form? Is there some other way i need to initialize the user form?
 

Some videos you may like

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

NdNoviceHlp

Well-known Member
Joined
Nov 9, 2002
Messages
2,515
Userform initialize is a userform event that happens when the userform is shown. U seem to be making your own sub.... it has nothing to do with the initialize event (unless U call it from userform initialize event). Anyways, I suspect that your subs are in the userform code. Place them in module code with "Public" in front of them (ie. Public Sub UserForm_Initialize(populatingArray() As Variant, positionOfOverWrite As Integer) ). U can then Call them from wherever. HTH. Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,109,550
Messages
5,529,472
Members
409,884
Latest member
Msinmath
Top