Solved

Eliminating blank spaces

Posted on 2013-01-21
7
200 Views
Last Modified: 2013-01-21
I'm sure this question has a very simple answer that I should know, but don't.  In the cells of column A are either a number or blank.  The numbers appear every so often, with the blank cells in between.  In column B I want to just show the numbers.  Example:

Column A        Column B
                            4
                            2
     4                     3
                            5
     2
     

     3

     5

How do I generate column B?
0
Comment
Question by:pwflexner
7 Comments
 
LVL 46

Accepted Solution

by:
Martin Liss earned 120 total points
ID: 38803151
In a macro.

Dim lngLastRow as Long
Dim lngIndex As Long
Dim lngRow As Long
lngLastRow = Range("A65536").End(xlUp).Row

lngRow = 2
For lngIndex = 2 To lngLastRow
    If Cells(lngIndex, 1).Value <> "" Then
        Cells(lngRow, 2).Value = Cells(lngIndex, 1).Value
        lngRow = lngRow + 1
    End If
Next

Open in new window

0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 38803169
Hello,

there are several ways.

Copy and paste the data, then sort the pasted values. Or use a formula

If you don't want to sort, you can use a helper column and a formula. Insert a column after column A and starting in row 2 (assuming row 1 has labels)

=IF(A2<>"",ROW(),"")

copy down

Then use in C2

=INDEX(A:A,SMALL(B:B,ROW(A1)))

copy down. Copy the result up to the error message and paste as values.

cheers, teylyn
0
 
LVL 24

Expert Comment

by:Steve
ID: 38803327
you could:

Add a filter to the top row.
Filter on Blanks in column A.
Highlight all rows
Press [ctrl]+[numpad minus]

This will delete all rows without values in the filtered column.
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:pwflexner
ID: 38803454
Actually the blank spaces in column A have a "" in them, if this matters...
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38803476
Well then in my code just substitute that character (which I can't make out) in this line

If Cells(lngIndex, 1).Value <> ""
0
 

Author Closing Comment

by:pwflexner
ID: 38803490
Thanks to all, but this answer worked best for my needs.
0
 
LVL 46

Expert Comment

by:Martin Liss
ID: 38803492
You're welcome and I'm glad I was able to help.

Marty - MVP 2009 to 2012
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

828 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