Solved

Excel: Automatically Fill Gaps Based on Cells Above

Posted on 2009-04-03
4
1,071 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
Comment Utility
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
Comment Utility
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
Comment Utility
saurabh726,
Your solution is cool. I didn't know about it.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now