Adding N/A to empty textboxes in userform

Patriot2879

Well-known Member
Joined
Feb 1, 2018
Messages
1,227
Office Version
  1. 2010
Platform
  1. Windows
Hello, Good afternoon please can you help me I have the code below where I am trying to add N/a to the empty textboxes in my userform if not filled but I am getting an error, please can you help me? I am getting an error on
Code:
Conventional.Show

Code:
Private Sub CommandButton3_Click()

Dim emptyRow As Long
With ThisWorkbook.Sheets("Handover")
   emptyRow = Cells(Rows.Count, "H").End(xlUp).Row + 1
 
   .Cells(emptyRow, 8).Value = TextBox8.Value
   .Cells(emptyRow, 9).Value = TextBox14.Value
   .Cells(emptyRow, 10).Value = TextBox7.Value
   .Cells(emptyRow, 11).Value = TextBox5.Value
   .Cells(emptyRow, 12).Value = TextBox3.Value
   .Cells(emptyRow, 13).Value = ComboBox5.Value
   .Cells(emptyRow, 14).Value = ComboBox3.Value
   .Cells(emptyRow, 15).Value = TextBox9.Value
   .Cells(emptyRow, 16).Value = ComboBox1.Value
   .Cells(emptyRow, 22).Value = TextBox11.Value
   .Cells(emptyRow, 20).Value = TextBox12.Value
    .Cells(emptyRow, 21).Value = TextBox13.Value
    .Cells(emptyRow, 23).Value = ComboBox4.Value
    .Cells(emptyRow, 25).Value = TextBox15.Value
    
        On Error Resume Next
            .SpecialCells(xlCellTypeBlanks).Value = "n/a"
        On Error GoTo 0
    End With
    Conventional.Show
Unload Me


End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Trial...
Code:
.SpecialCells(xlCellTypeBlanks).Text = "n/a"
HTH. Dave
ps. I think U need to loop the range and check if the cell is blank then insert "N/A"
 
Upvote 0
HI thank you for the reply i have just tried the amendment but still getting the error on
Code:
Conventional.Show
, hope you can help
 
Upvote 0
Hello,

You are getting an error ... because of the term ' Conventional ' ...

What is it exactly ...???

If you need to show a Userform ... YourUserFormNAME.Show

Hope this will help
 
Upvote 0
Hello, I have changed it to... UserForm3.Show, but still getting the same error :(
 
Upvote 0
Hello,

Do you mind explaining exactly what you are trying to accomplish ...

My understanding is as follows ... macro adjusted for the first 5 TextBoxes ...

Code:
Private Sub CommandButton3_Click()
Dim emptyRow As Long
With ThisWorkbook.Sheets("Handover")
   emptyRow = .Cells(Rows.Count, "H").End(xlUp).Row + 1
 
   .Cells(emptyRow, 8).Value = IIf(TextBox8.Value = "", "NA", TextBox8.Value)
   .Cells(emptyRow, 9).Value = IIf(TextBox14.Value = "", "NA", TextBox14.Value)
   .Cells(emptyRow, 10).Value = IIf(TextBox7.Value = "", "NA", TextBox7.Value)
   .Cells(emptyRow, 11).Value = IIf(TextBox5.Value = "", "NA", TextBox5.Value)
   .Cells(emptyRow, 12).Value = IIf(TextBox3.Value = "", "NA", TextBox3.Value)
   .Cells(emptyRow, 13).Value = ComboBox5.Value
   .Cells(emptyRow, 14).Value = ComboBox3.Value
   .Cells(emptyRow, 15).Value = TextBox9.Value
   .Cells(emptyRow, 16).Value = ComboBox1.Value
   .Cells(emptyRow, 22).Value = TextBox11.Value
   .Cells(emptyRow, 20).Value = TextBox12.Value
   .Cells(emptyRow, 21).Value = TextBox13.Value
   .Cells(emptyRow, 23).Value = ComboBox4.Value
   .Cells(emptyRow, 25).Value = TextBox15.Value
End With
Unload Me
End Sub

Hope this will help
 
Upvote 0
that's done it, great, many thanks :) again you are brilliant with your help, much appreciated
 
Upvote 0

Forum statistics

Threads
1,214,615
Messages
6,120,538
Members
448,970
Latest member
kennimack

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