Sort and eliminate blanks

alainfranco

New Member
Joined
Mar 7, 2012
Messages
38
Hello,

Newby quesiton here to keep you on your toes! ;)

How would I clean up a list in a column refered to by a named range, and copy the results to another column?

In other words, I have a list of fields whichm based on a vlookup, returns cities (or not) to column A. This list sometimes contains a result, sometimes not.

I need a clean list, meaning that I would need to have all blank resultst filtered out. But since I am using this result list as an input to another formula, I would need it to be cleared of blanks and copied over to the next column over.

Any advice on how to do this?

Thanks :)
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Does this work...

Code:
Sub CopyNoBlanks()


    With ActiveSheet.Range("NamedRange")  'Change to your Named Range
        .AutoFilter Field:=1, Criteria1:="<>"
        .SpecialCells(xlVisible).Copy
        .Offset(0, 1).PasteSpecial Paste:=xlPasteAll
        .Cells(1).Select
    End With
    ActiveSheet.ShowAllData
    ActiveSheet.AutoFilterMode = False


End Sub
 
Upvote 0
Does this work...

Code:
Sub CopyNoBlanks()


    With ActiveSheet.Range("NamedRange")  'Change to your Named Range
        .AutoFilter Field:=1, Criteria1:="<>"
        .SpecialCells(xlVisible).Copy
        .Offset(0, 1).PasteSpecial Paste:=xlPasteAll
        .Cells(1).Select
    End With
    ActiveSheet.ShowAllData
    ActiveSheet.AutoFilterMode = False


End Sub


Hi,

Sorry for the delay, I was away.

No, it does not work. at least not completly.

It does copy information over one column and does seem to sort to a certain level, but because the sorted data is the result of a formula, the macro copies the formula, which is not exactly the intended objective.

Any other idea friend? :)
 
Upvote 0
Other than in the title of your post you did not specify what kind of sort you wanted. If you provide the criteria for the sort, it could be written into the code.

Do you want just the values copied over or exactly what. If you could articulate what is exactly the intended objective, that would go a long way toward a successful conclusion.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,952
Messages
6,175,593
Members
452,654
Latest member
mememe101

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top