Filter - function

denton

New Member
Joined
Oct 17, 2006
Messages
20
I have some cells in column A filled with numbers and some are empty->eg. in A1 is number, A2 number, A3 empty,A4 empty,A5 number,A6 empty etc.
I need some function to collect only not empty cells in column A and write those cells to another column. So in C1 is number from A1,C2->A2,C3->A5. Can anyone help me?
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Hi

1. apply an Autofilter to the range.
2. filter the nonblanks (i.e. after left clicking the down triangle appearing)
3. select the filtered cells, and do a normal Copy and then Paste where you want the data.

Wigi
 
Upvote 0
Hello denton, welcome to the board.
For a quick little macro to do what wigi is suggesting:
Code:
Sub Demo()
With Application
  .ScreenUpdating = False
  With Columns("A:A")
    .AutoFilter Field:=1, Criteria1:="<>"
    .Copy Range("C1")
  End With
  ActiveSheet.AutoFilterMode = False
  .CutCopyMode = False
  .ScreenUpdating = True
End With
End Sub
 
Upvote 0
Hi

1. apply an Autofilter to the range.
2. filter the nonblanks (i.e. after left clicking the down triangle appearing)
3. select the filtered cells, and do a normal Copy and then Paste where you want the data.

Wigi

but...if i do this, it will copy only first block of non empty cells, not all filtered selection. try it...
 
Upvote 0
Hello denton, welcome to the board.
For a quick little macro to do what wigi is suggesting:
Code:
Sub Demo()
With Application
  .ScreenUpdating = False
  With Columns("A:A")
    .AutoFilter Field:=1, Criteria1:="<>"
    .Copy Range("C1")
  End With
  ActiveSheet.AutoFilterMode = False
  .CutCopyMode = False
  .ScreenUpdating = True
End With
End Sub

working perfectly! What if i want to do this with 2 columns in sheet1 and results want to have in column C and D (for both columns) in sheet2 ?
 
Upvote 0
but...if i do this, it will copy only first block of non empty cells, not all filtered selection. try it...

Yes, it does. You need to select all the cells before applying the autofilter. Try it...
 
Upvote 0
but...if i do this, it will copy only first block of non empty cells, not all filtered selection. try it...

Yes, it does. You need to select all the cells before applying the autofilter. Try it...

perfect! it works! dont know why didnt it work before. Do you think you can help me? I need to make some macro which will copy those numbers to other sheet, but...i have table 40x4 cells (C1:F40). Imagine that filter will find cca 100 numbers- i need to put these numbers to table C1:F40 in sheet2 ->first 40 numbers will be in C1:C40, the 41st will be in D1 and so on,81 st in E1. It is easy to make it handy, but I'd like to make some macro. Would be great if you can help me.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,254
Members
448,556
Latest member
peterhess2002

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