blanket "if null" statement

synergy16

Active Member
Joined
Mar 17, 2016
Messages
422
Office Version
  1. 365
Platform
  1. Windows
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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
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
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,300
Members
452,633
Latest member
DougMo

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