Copy range if cells are blank

skinnyboy

New Member
Joined
Dec 28, 2018
Messages
4
I have range D2:D40 with data that gets updated chronologically from left to right. (D2 on Monday, D3 Tuesday, D4 Friday, etc). If we haven't reached the time of the update, then the cell is going to be blank. I also have H2:H40 that all has data. I want to create a macro that checks row D to see if the cells are blank, and if they are, replace them with the information in the corresponding column from row H (copy H10 to D10, H11 to D11, etc). Is there a simple way to do this? Does it help to know that if D10 is blank, then D11:D40 are also going to be blank?
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Code:
With [D2:D40].SpecialCells(xlCellTypeBlanks)
    .Value = .Offset(0, 4).Value
End With
 
Upvote 0
Oops, sorry! I typed my original question from memory and got it wrong as to how the data was laid out.

The range that gets manually updated is all in row 4. It's C4, E4, G4... CC4. (C4 & D4 are merged into 1 cell, as are E4 & F4, etc). I want to copy the data from row 10 - so that if M4 is blank, it's set to the value of M10.

Can this still be done?
 
Upvote 0
Code:
Dim r As Range, c%
Set r = [D4:CC4]
For c = 1 To r.Cells.Count Step 2
    If r(c) = "" Then r(c).Value = r(7, c).Value
Next
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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