Solved

Excel: Automatically Fill Gaps Based on Cells Above

Posted on 2009-04-03
4
1,076 Views
Last Modified: 2012-05-06
How do I automatically fill in the gaps in a column based on the values in the cell above.
Eg Cell A1 says "MR X", Cell A10 says "Mr Y" and Cell A20 says "Mr Z"
What is the macro that would automatically fill down to show the following ( I need a macro as Ithere is too much data to do a manual fill down). Thanks!

A1 Mr X
A2 Mr X
A3 Mr X
A4 Mr X
A5 Mr X
A6 Mr X
A7 Mr X
A8 Mr X
A9 Mr X
A10 Mr Y
A11 Mr Y
etc etc etc etc...





0
Comment
Question by:doolinn
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
Saurabh Singh Teotia earned 500 total points
ID: 24061418
Just follow these steps, You will be able to do what you are looking for...
  • Press F5  and then press special and hit ok
  • Hit Blanks and hit ok which will select the blank cells only.
  • Then in on of the blank sell do a reference to the cell above and enter it by ctrl+enter
This will show data in all the cells automatically which will have the fomrula in it.
Saurabh...
0
 
LVL 15

Expert Comment

by:yuk99
ID: 24061507
You can use this macro if your column is large.
Sub FillGaps()

If Selection.Cells(1, 1) = "" Then

    MsgBox "First cell is empty!", vbCritical

Exit Sub

End If

For Each c In Selection

    If c.Value = "" Then

        c.Value = c.Offset(-1, 0).Value

    End If

Next

End Sub

Open in new window

0
 
LVL 15

Expert Comment

by:yuk99
ID: 24061659
saurabh726,
Your solution is cool. I didn't know about it.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
Many companies are making the switch from Microsoft to Google Apps (https://www.google.com/work/apps/business/). Use this article to learn more about what Google Apps has to offer and to help if you’re planning on migrating to Google Apps. It is …
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now