finaljustice
Board Regular
- Joined
- Oct 6, 2010
- Messages
- 175
Hello, I have designed a userform and I have two problems which I don't know how to fix.
1) How do I call an object from another userform? My workbook has two userforms, what I want to do is from userform2 call a combobox in userform1 (which iniciates several procedures). I am able to call the combobox if its on the same userform, but not in different ones. How can this be done?
Here is the code for the button wich at the end I want to call the combobox from userform one.
2) I have to format a textbox to accept only numbers, so i came up with this code:
This code kinda works but I figured it could be better and it gives me some problems when doing other things. I would like to know how to fix these two problems I can't seem to figure out:
Thank you in anticipation for your attention and your help!
1) How do I call an object from another userform? My workbook has two userforms, what I want to do is from userform2 call a combobox in userform1 (which iniciates several procedures). I am able to call the combobox if its on the same userform, but not in different ones. How can this be done?
Here is the code for the button wich at the end I want to call the combobox from userform one.
Code:
Sub CommandButton1_Click()
Dim x As String
Dim y As String
Dim z As String
MsgBox "A projeção inserida preecherá automaticamente de fevereiro a novembro." & vbCrLf & "Adicione janeiro e dezembro manualmente na tela anterior." & vbCrLf & "Clique em ATUALIZAR para as informações na tela sejam atualizadas."
x = txtproj1
y = txtproj2
z = txtproj3
n = 0
Do Until n = 8
ActiveCell.Offset(0, 51 + n) = x
n = n + 1
Loop
n = 0
Do Until n = 10
ActiveCell.Offset(0, 61 + n) = y
n = n + 1
Loop
n = 0
Do Until n = 10
ActiveCell.Offset(0, 73 + n) = z
n = n + 1
Loop
Call cboNome2 'this combobox is in userform1 while this button is in userform2
UserForm2.Hide
End Sub
2) I have to format a textbox to accept only numbers, so i came up with this code:
Code:
Private Sub txtCDIC_Change()
If Not IsNumeric(txtCDIC) Then
MsgBox "Please insert only numbers"
End If
End Sub
- If someone inserts something that is not a number the msg appears, but when that person presses BACKSPACE to correct that, the msg will also appear (Giving it a "buggy" feel)
- When the textbox retrieves information from a cell and that cell is empty the msg also appears.
Ideally the textbox should accept only numbers and users when write in it should be able to press backspace without the msg appearing and when I import the data from the cells, if they are blank the msg shouldnt appear.
So those are my doubts, I would really appreciate the help since I have no clue nor have I found solutions for these problems.
Thank you in anticipation for your attention and your help!