If cell is blank, return value from a different cell

nkarnes

New Member
Joined
Jul 28, 2017
Messages
1
If the cell B is blank, then enter the data from A.
If cell B is NOT blank, then skip.

Column A Column B
[TABLE="width: 500"]
<tbody>[TR]
[TD]State1[/TD]
[TD]State 2[/TD]
[/TR]
[TR]
[TD]MI[/TD]
[TD]MI[/TD]
[/TR]
[TR]
[TD]OH[/TD]
[TD]if this is blank, enter data from A2[/TD]
[/TR]
[TR]
[TD]KY[/TD]
[TD]if this row is blank, enter data from A3[/TD]
[/TR]
[TR]
[TD]WV[/TD]
[TD]WV[/TD]
[/TR]
[TR]
[TD]IN[/TD]
[TD]if this row is blank, enter data from A5[/TD]
[/TR]
</tbody>[/TABLE]

****** id="cke_pastebin" style="position: absolute; top: 131.2px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">[TABLE="width: 500"]
<tbody>[TR]
[TD]if this is blank, enter data from A2[/TD]
[/TR]
</tbody>[/TABLE]
</body>Can you help?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Hi & welcome to MrExcel.
How about
Code:
Sub FillB()
   With Range("B2", Range("A" & Rows.Count).End(xlUp).Offset(, 1))
      .Value = Evaluate(Replace(Replace("If(@="""",@a,@)", "@a", .Offset(, -1).Address), "@", .Address))
   End With
End Sub
 
Upvote 0
Try
Code:
With Range("B:B").SpecialCells(xlCellTypeBlanks)
    .FormulaR1C1 = "=RC[-1]"
    .Value = .Value
End With
 
Upvote 0
Mike
Your code will copy the values from the first area into all other areas.
 
Upvote 0
Tend to forget that myself sometimes.
But doing it like this should work
Code:
With Range("B:B")
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=RC[-1]"
    .Value = .Value
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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