# blanket "if null" statement

#### synergy16

##### Active Member
good morning all. after a bunch of calculations i narrow down a single row based on user choice and populate textboxes with related data. some of the cells are blank tho. is there a way to, perhaps with a loop, to tell the program if any of those cell locations are null to put a "N/A" in the textbox or do i have to a if/then statement for each one?

Code:
serialNumTB = Cells(stripPartRow, 7)    partQtyTB = Cells(stripPartRow, 5)
partRevTB = Cells(stripPartRow, 4)
lotBatchTB = Cells(stripPartRow, 6)
jobProOrderTB = Cells(stripPartRow, 8)
supplierTB = Cells(stripPartRow, 9)
shipOutDateTB = Cells(stripPartRow, 10)
origPoDate = Cells(stripPartRow, 11)
expDockDateTB = Cells(stripPartRow, 12)
customerTB = Cells(stripPartRow, 2)
relatedPrtTB = Cells(stripPartRow, 13)
notesTB = Cells(stripPartRow, 14)

### Excel Facts

Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)

#### Fluff

##### MrExcel MVP, Moderator
If the textboxes are on a userform try
Code:
Dim Ary As Variant
Dim i As Long

Ary = Array("serialNumTB", 7, "partQtyTB", 5, "partRevTB", 4)
For i = 0 To UBound(Ary) Step 2
If Cells(stripPartRow, Ary(i + 1)) = "" Then
Me.Controls(Ary(i)) = "N/A"
Else
Me.Controls(Ary(i)) = Cells(stripPartRow, Ary(i + 1))
End If
Next i

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,164,016
Messages
5,834,943
Members
430,327
Latest member
Mr_Himalayan778

### 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.

### Which adblocker are you using?

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

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