Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Eliminating blank spaces

Posted on 2013-01-21
7
Medium Priority
?
215 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
[X]
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
7 Comments
 
LVL 49

Accepted Solution

by:
Martin Liss earned 480 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
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

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

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 49

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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 descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

670 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