Code for last post with a few more explaining Comments and colour conventions to suit the last Posts # 16 and #17 ( Posted here due to Forum Post size limitations: )
oRefiginal Class UserForm1.
Code:Sub KloneAUserFormWonks() ' ' Post #16 http://www.excelforum.com/showthread.php?t=1138300&p=4383265&highlight=#post4383265 Dim ws As Worksheet ' ' Preparing a "Pointer" to an Initial "Blue Print" ( or a Form, or a Questionnaire not yet filled in, a template etc.) in Memory of the Object ( Pigeon Hole with a bit of paper or code lines on that can be filled in to refer to a specific Object of this type ) . This also us to get easily at the Methods and Properties through the applying of a period ( .Dot) ( intellisense ) Set ws = ThisWorkbook.Worksheets.Item(1) ' Values are filled at the memory locations and the directions there are specified in the variable "Blue Print "Pointer". In this case a Filled in Blue Print is passed. This is the one used on Opening by Excel to call up the user Friendly Form of the Fiist Tab Worksheet counting from the left. Dim fm1 As UserForm1 ' Set fm1 = New UserForm1 ' ' A copy of the Blue Print is made fm1.Left = 0 fm1.CheckBox1.Value = True fm1.Show vbModeless ' there are two ways ( modes ) of showing a form in vb - modal and modeless. a modal form takes the focus and won't return control to the calling module until it is closed. a modeless form is shown and then control is immediately returned to the calling module. http://vbcity.com/forums/t/53342.aspx Dim fm2 As UserForm1 Set fm2 = New UserForm1 fm2.Show vbModeless fm2.Caption = "Klone fm2" fm2.Left = 50 ' Dim UserForm1 As UserForm1 ' These two imaginary lines are effectively done by ' Set UserForm1 = New UserForm1 ' VBA on compile when it sees the next line. Thes lines you would never see UserForm1.Caption = "This one VBA decalred and Instanced for me" UserForm1.Show vbModeless UserForm1.Height = 50 UserForm1.Left = 200 End Sub




Reply With Quote
Bookmarks