SOme problem on VBA Userform

  • Thread starter Thread starter allissonlu
  • Start date Start date
A

allissonlu

Hi,

I am using Excel 2002, and I am new to VBA in Excel.

I created a userform (named frmCost) within an Excel file, and on on
of the Excel sheets, I added a button (called BtnStart) to control th
loading of the userform.

The codes are:

Private Sub BtnStart_Click()
Dim frmCostCal As New frmCost

With frmCostCal

.Show

End With

End Sub

Also on the userform, I added an "exit" button to unload the userfor
and return to Excel. The codes are:

Private Sub btnExit_Click()

Unload Me

End Sub


The problem is, sometimes when I click the "Start" button, the Exce
crashes. This happens randomly, esp. when the button is clicked righ
after opening the Excel file.

Any help or advice will be highly appreciated.

Alliso
 
Hi Allison,

You need to load the form before showing it.

Private Sub BtnStart_Click()
Dim frmCostCal As New frmCost
Load frmCostCal
frmCostCal.Show
End Sub

HTH, Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Some problem with Excel VBA Userform 2
VBA userform Vlookup Excel 1
UserForm_Terminate problem 1
Hidden sheet bleeds through 3
UserForm Issues 6
UserForm Option Button 6
Userform is blank 4
automation error 0

Back
Top