I have a User Form with a number of Refedit controls. The object is for the operator to select a number of cells on a work sheet each selection will provide the column number and those in turn will be used to create a new sheet with data from those columns using the union command.
My problem is that in testing the form if I selected a cell and then click the close button it does not call the sub routine in fact it closes the form even without an unload command.
This is the code so far behind the userform
Private Sub CommandButton1_Click() Call TestForm End Sub Private Sub ProdDate_Change() ‘This is the 2nd RefEdit control ProdDateCol = Range(UserForm2.proddate.Value).Column ProdDate.Text = “Column ” & ProdDateCol End Sub Private Sub WellName_Change() ‘This is the 1st RefEdit control WellNameCol = Range(UserForm2.WellName.Value).Column WellNameCol.Text = “Column ” & WellNameCol ‘Move to the next control ‘ProdDate.SetFocus End Sub
In separate module is the code that I want to use to test if the correct information is being passed but I cannot get there. Both WellNameCol and ProdDateCol are declares as Public variables in the module. This is the code I do not get to.
Sub TestForm() MsgBox (“Well Name Column ” & WellNameCol & Chr(13) & _ “Product Date Column” & ProdDateCol) End Sub
If I click the Command button with out 1st selecting data in the Regedit cells it takes me to the routine TestForm. Just discovered trying to move from one Regedit to another closes the form so maybe I have corrupted it somehow. I know RefEdit is considered a tricky control.
Any thoughts greatly appreciated
Peter