Ned help with Fill

Sean15

Well-known Member
Joined
Jun 25, 2005
Messages
719
Office Version
  1. 2010
Platform
  1. Windows
Hi:

I need to fill a large worksheet as follows:
all blank rows that follows a cell with a value should be filled with that cell value.
For example in column C below, C5, C6, C7 should be filled with value in C4.
Value in C8 must stay as is but C11, CC12 must be filled with value in C8

The same will apply to column D, E and F

Could someone help please?



Excel 2010
CDEF
2CheckDateAcctName
336632907/27/1863358John Peter
436657008/24/1863358John Peter
5
6
7
836128903/24/17467Mike James
9
1036136103/31/1763404Joan Yell
11
12
13Required values:
14CheckDateAcctName
1536632907/27/1863358John Peter
1636657008/24/1863358John Peter
1736657008/24/1863358John Peter
1836657008/24/1863358John Peter
1936657008/24/1863358John Peter
2036128903/24/17467Mike James
2136128903/24/17467Mike James
2236136103/31/1763404Joan Yell
Sheet2
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Hi,

Enter this formula in C5:

=C4

1. With C4 selected, right click, Copy
2. Drag selected C4 down and across to F10
3. Hit F5 (NOT the cell - F5 on your keyboard)
4. In the Go To pop up, click "Special", select "Blanks"
5. Click OK, then Enter

Format Column D as Date
 
Last edited:
Upvote 0
Hi:

I'm sure I am doing something wrong but suggestion in post #2 is filling value in C4 in C5 to D7 only.

Sean15 said:
I need to fill a large worksheet as follows:

Sorry I should have mentioned worksheet has 17,000+ rows so suggestion in post #2 would be cumbersome.
 
Last edited:
Upvote 0
Try this:
Code:
Sub Filldown_Please()
'Modified 9/29/2018 8:59 PM  EDT
Application.ScreenUpdating = False
Dim i As Long
Dim Lastrow As Long
Lastrow = Cells(Rows.Count, "C").End(xlUp).Row
For i = 3 To Lastrow
    If Cells(i, "C").Value = "" Then Cells(i, "C").Resize(, 4).Value = Cells(i, "C").Offset(-1).Resize(, 4).Value
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Sean15, in the example you have 3 blank rows under "John Peter". If you have, say, 100 blank rows below a name, this may not work. But here's a brute force way to clean things up:

1. In cell G3 type: =if(isblank(c3),1,c3). Copy this into columns H, I, and J in order to match your other data columns. Drag the formulas down to Row 18000 (per your post of 17k +rows)
2. In cell K2 type: =countif(k3:k17000,"=1"). This will tell you if you have blanks left.
3. In cell K3 type: =if(g3=1,g2,g3). Copy this formula all the way from K3 to AA18000
4. Copy the formula in K2 all the way to AA2. If the number in AA2 is NOT 0, you will need to continue Step 3 out to, say ZZ18000, etc...

You will eventually have no blank rows and you can just copy and paste values into a new, fresh Tab!
 
Upvote 0
I have assumed
- that your data column is formatted with a Date format, not General. If General, one extra line may be needed in the code.
- that the 'blank' cells are in fact blank and not formulas returning "".
- these columns do not contain any formulas that need to be retained as formulas.

In that case there should be no need to loop through the blank 'sections' or individual rows but do them all at once.
Test with a copy of your workbook.

Code:
Sub FillBlanks()
  Application.ScreenUpdating = False
  With Intersect(ActiveSheet.UsedRange, Columns("C:F"))
    .SpecialCells(xlBlanks).FormulaR1C1 = "=R[-1]C"
    .Value = .Value
  End With
  Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi:

Thanks for help.

Tested code on 337 rows.

Code in post #4 work works flawlessly.

Code in post #6:
Inserted dates in column C.
Did not insert any values in column E and F.
Inserted values in column C & D beyond the test range of 337 rows. Values inserted all the way to row 16947.


Regards,
 
Last edited:
Upvote 0
Code in post #6:
Did not insert any values in column E and F.
Then the 'blank' cells in columns E:F are not actually empty. Ref my second assumption (though there are also ways other than a formula returning "" that can make a cell appear blank but not actually be empty)


Inserted values in column C & D beyond the test range of 337 rows. Values inserted all the way to row 16947.
That was deliberate. In your sample, John Peter & Mike James require rows to be filled. Is it not possible that Joan Yell may also need some blanks filled? If so, how would we know how far to fill those values?
I used the assumption that if there is data elsewhere in your sheet (eg columns A:B) that might determine where the fill should go to. Looks like that as a wrong assumption.

Anyway, you have something that works. With 17,000+ rows and 4 columns I thought that might take a bit of time with MAIT's suggested code so was trying for a way to do it all at once. If it was possible to determine what is happening with those 'blanks' in columns E & F, it still may be possible to process the whole range at once if you wanted to pursue that possibility.
 
Last edited:
Upvote 0
Sorry, meant to post earlier, but LH (life happens)

If you actually posted a copy of your real data, there're spaces in Columns E & F, so you'll need to clean those up first before any formula can work...

Edit: once you've cleaned up the spaces in E & F, to copy the formula down 17000 rows (or more) is not difficult at all...
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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