Solved

If cell below me blank, copy and paste my value to it. If not blank and not equal to me, repeat with new value.  36,000 rows, 1 column.

Posted on 2011-03-04
3
427 Views
Last Modified: 2012-05-11
I have a spreadsheet with 36,000 rows of data. I am focusing on one column, Column A.

The column begins with Value 1 in the first row, followed by some blank rows, and then a row with Value 1 again.
As you continue down the column, there are more blank rows and different values in the non-blank rows (Value 2, Value 3, etc.).
I need some automated way to start in cell A1 and evaluate so that "If cell below me is blank, paste me there. If cell below me is not blank and not equal to me, paste different-valued-cell to cell below it, if that cell is blank."
In other words, the blank cells need to have the value of the most-recent non-blank cell, until a new value is reached. Then, the new value needs to be pasted in the blank rows below that value, until a new value, etc.

Please see the attached files to see what I am going for. There is a .xls file (for compatibility. I am using Excel 2007.) as well as a .PNG image (both of the same thing).

Your help would be greatly appreciated, as I have other sheets where I need to do the same thing. Thank you in advance.

IfThenRules-ExampleSheet.xls
IfThenExample.png
0
Comment
Question by:nicholasjwolf
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 35039074
Here is a code that will do this for all selected sheets

Thomas

Sub asdgasdg()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
    With ActiveSheet.UsedRange.Resize(ActiveSheet.UsedRange.Rows.Count + 10).Columns(1)
        .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
        .Copy
        .PasteSpecial Paste:=xlPasteValues
    End With
Next

End Sub

Open in new window

0
 

Author Comment

by:nicholasjwolf
ID: 35039172
nutsch,
      I love you!! This is exactly what I needed!
0
 
LVL 39

Expert Comment

by:nutsch
ID: 35039290
Glad to help, thanks for the grade.

Thomas
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My experience with Windows 10 over a one year period and suggestions for smooth operation
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question