User Form -Empty Textboxes

yeminbek

New Member
Joined
Jun 29, 2012
Messages
2
Hi friends,.thanks for any help.

I have a userform and it has 50 text boxes in it. and I write the values in the textboxes to the excell sheet when user press click on the userform.

My problem is; generally i dont need to fill all text boxes. For example I fill 5 of them. And when I click, I see these 5 values in the excel sheet as expected.

However when I use Application.CountA.....vba code to count the cells which is not empty, it always shows 50...However 5 of the cells shows value.

Any help really appreciated, I am in trouble
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
When you click, you should go through the textboxes and only add the ones that have some text and not the empty ones.
 
Upvote 0
Thank you very much..I am adding all the text boxes with below code...How can I add only text boxes which has values?

Private Sub CommandButton1_Click()

Dim i As Double
For i = 1 To 50
ThisWorkbook.Sheets("Sheet6").Cells(i , 1).Value = UserForm1.Controls("textbox" & i)

Next i

UserForm1.Hide
End Sub
 
Upvote 0
Code:
Private Sub CommandButton1_Click()
    Dim i As Integer
    For i = 1 To 50
        If Trim(UserForm1.Controls("textbox" & i).Text) <> "" Then
            ThisWorkbook.Sheets("Sheet6").Cells(i, 1).Value = UserForm1.Controls("textbox" & i)
        End If
    Next i
    UserForm1.Hide
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,744
Members
448,989
Latest member
mariah3

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