Fill in blanks with N/A in the next row

quadaxel

New Member
Joined
Jul 25, 2020
Messages
5
Office Version
  1. 2016
Platform
  1. Windows
My code below helps me to fill in blank cells with N/A from range A18:Y18. However, I'm not sure how to run the same code for the next rows (ie A19:Y19, A20:Y20).

My usual process is to enter the raw data into row 18 first, then run this VBA code to fill in blank cells with N/A. Next, I will enter another set of data into row 19, and fill in the blanks with N/A. I want to repeat this process for each row. How should I edit my code?

VBA Code:
Sub FillEmptyCells()
'Forces each cell to show N/A if Empty
On Error Resume Next
Dim c As Range
Dim rng As Range
Set rng = Range("A18:Y18")
    For Each c In rng
If IsEmpty(c) Then
c = "N/A"
End If
Next c
End Sub
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Welcome to the Forum, would this work for you.

VBA Code:
Sub checkCell()
Range("A18").CurrentRegion.SpecialCells(xlBlanks).Value = "n/a"
End Sub
 
Upvote 0
Thank you for your help. However, the code above helps to fill in N/A into the blank cells. Is there any way to help me to fill in N/A into the next row's blank cells, without me having to edit the range?
 
Upvote 0
The CurrentRegion will extend down automatically when you add more data, each time you run the code it will fill in N/A in any empty cell.
 
Upvote 0
Oh I see...

I ran into another issue when I run the code. My rows above row 18 are affected. Those rows already contained data, but how did those data get replaced with N/A as well?

The CurrentRegion will extend down automatically when you add more data, each time you run the code it will fill in N/A in any empty cell.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,851
Members
449,051
Latest member
excelquestion515

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