Userform help (textbox format & call object)

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.
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
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:
  • 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!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,214,649
Messages
6,120,728
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top