blanket "if null" statement

synergy16

Active Member
Joined
Mar 17, 2016
Messages
409
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

Add Bullets to Range
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
Joined
Jun 12, 2014
Messages
73,212
Office Version
  1. 365
Platform
  1. Windows
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
 
Master Excel Bundle

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.

Forum statistics

Threads
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.
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
Top