excel vba- userform problem

K

knight4

I am working on a program that includes some vba code to create
userform, together with associated controls, ie buttons and imag
controls. This is working fine, but i now need to find a way to remov
the userform from within vba. The user form is created from data on a
excel worksheet, if the user changes the information on the workshee
then i need to remove the userform and then recreate it so that i
picks up the latest information. Does anybody know of a way that i ca
achieve this using vba? I would appreciate any ideas you may have

Many thanks

Knight
 
B

Bob Phillips

This code will completely remove a module

Dim VBComp As VBComponent

Set VBComp = ThisWorkbook.VBProject.VBComponents("Userform1")
ThisWorkbook.VBProject.VBComponents.Remove VBComp

You need to add a reference to the Visual Basic for Applications
Extensibility library, but you probably already have that for the other
code.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 

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

Top