ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SOme problem on VBA Userform (https://www.excelbanter.com/excel-programming/306823-some-problem-vba-userform.html)

allissonlu

SOme problem on VBA Userform
 
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 a

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 a

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

--
Message posted from http://www.ExcelForum.com


Greg Koppel

SOme problem on VBA Userform
 
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

"allissonlu " wrote in message
...
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 one
of the Excel sheets, I added a button (called BtnStart) to control the
loading of the userform.

The codes a

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 userform
and return to Excel. The codes a

Private Sub btnExit_Click()

Unload Me

End Sub


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

Any help or advice will be highly appreciated.

Allison


---
Message posted from http://www.ExcelForum.com/




allissonlu[_2_]

SOme problem on VBA Userform
 
It crashes again


---
Message posted from http://www.ExcelForum.com/



All times are GMT +1. The time now is 09:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com