ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete userforms in vba (https://www.excelbanter.com/excel-programming/384545-delete-userforms-vba.html)

malpropio

delete userforms in vba
 
Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx


Jim Jackson

delete userforms in vba
 
In the code window, right-click on the user-form name in the left column and
select "Remove Userform".
--
Best wishes,

Jim


"malpropio" wrote:

Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx



Tom Ogilvy

delete userforms in vba
 
in the project explorer in the VBE, right click on you userform entry under
the appropriate workbook and select remove.

--
Regards,
Tom Ogilvy


"malpropio" wrote:

Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx



malpropio

delete userforms in vba
 
Thk u Tom and Jim,
But I don't know if its because I'm using the vb code editor of excel
but when I right click on the userform in the project explorer it does
not give me the choice to delete it.

malpropio


JLGWhiz

delete userforms in vba
 
You must right click on the form you want to remove, not just in the project
window.

"malpropio" wrote:

Thk u Tom and Jim,
But I don't know if its because I'm using the vb code editor of excel
but when I right click on the userform in the project explorer it does
not give me the choice to delete it.

malpropio



Chip Pearson

delete userforms in vba
 
If you want to do this by code, set a reference to the VBA 5.3 Extensibility
Library (in VBA, go to the Tools menu, choose References, and check
"Microsoft Visual Basic For Applications Extensibility Library 5.3"). Then
use code like

Sub DeleteForm()
Dim VBComps As VBIDE.VBComponents
Dim VBComp As VBIDE.VBComponent
Set VBComps = Workbooks("Book1.xls").VBProject.VBComponents
Set VBComp = VBComps("UserForm1")
VBComps.Remove VBComp
End Sub

See www.cpearson.com/excel/vbe.htm for more details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"malpropio" wrote in message
oups.com...
Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx




Chip Pearson

delete userforms in vba
 
Or, simpler, without needing a library reference:

Sub DeleteForm()
With Workbooks("Book1.xls").VBProject.VBComponents
.Remove .Item("UserForm1")
End With
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Chip Pearson" wrote in message
...
If you want to do this by code, set a reference to the VBA 5.3
Extensibility Library (in VBA, go to the Tools menu, choose References,
and check "Microsoft Visual Basic For Applications Extensibility Library
5.3"). Then use code like

Sub DeleteForm()
Dim VBComps As VBIDE.VBComponents
Dim VBComp As VBIDE.VBComponent
Set VBComps = Workbooks("Book1.xls").VBProject.VBComponents
Set VBComp = VBComps("UserForm1")
VBComps.Remove VBComp
End Sub

See www.cpearson.com/excel/vbe.htm for more details and example code.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"malpropio" wrote in message
oups.com...
Hey everyone,
I'm trying to get rid of a form I created in a project so I can
import another one which has the same name.
But so far I havent been able to find a way to do it.
So please let me know if thats possible and if not what would be the
solution to my problem.

Thx






Tom Ogilvy

delete userforms in vba
 
I didn't say to right click on the userform itself. Re read my post.

All actions are performed in the project explorer window (defaults to the
upper left of the VBE). You right click on the name of the Useform as
shown in the project explorer.

--
Regards,
Tom Ogilvy

"malpropio" wrote in message
oups.com...
Thk u Tom and Jim,
But I don't know if its because I'm using the vb code editor of excel
but when I right click on the userform in the project explorer it does
not give me the choice to delete it.

malpropio





All times are GMT +1. The time now is 01:29 PM.

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