Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Excel: Automatically Fill Gaps Based on Cells Above

Posted on 2009-04-03
4
1,087 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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

856 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