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
State1State 2
MIMI
OHif this is blank, enter data from A2
KYif this row is blank, enter data from A3
WVWV
INif this row is blank, enter data from A5

<tbody>
</tbody>

****** id="cke_pastebin" style="position: absolute; top: 131.2px; width: 1px; height: 1px; overflow: hidden; left: -1000px;">
if this is blank, enter data from A2

<tbody>
</tbody>
</body>Can you help?
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
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,216,069
Messages
6,128,599
Members
449,460
Latest member
jgharbawi

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