Filtering/Sorting Data

Pumper

Board Regular
Joined
Sep 12, 2013
Messages
95
Office Version
  1. 2016
Hi All, I have a list of data and would like to return only rows that are not 0 in cell C and adjust the order of one of the columns

ie column C goes to column B once filtered and column C would be 0 if that row is not blank

Any help would be much appreciated

ExcelQuestion.JPG
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
You haven't told us whether you are looking for a formula approach, vba or perhaps Power Query?

You also don't show us what version(s) of Excel you are using. Please update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

I also suggest that you investigate XL2BB for providing sample data to make it easier for helpers by not having to manually type out sample data to test with.

One more thing, I do not know what you mean by this.
column C would be 0 if that row is not blank
 
Upvote 0
Try this Formula:
Book1
ABCDE
1FundTargetTrade
2ABC10
3DEF25
4GHI30
5JKL4-14
6
7
8FundTradeshould have zero if not Blank
9DEF50
10JKL-140
11 
Sheet1
Cell Formulas
RangeFormula
B9:B10B9=VLOOKUP(A9,$A$2:$C$5,3,FALSE)
A9:A11A9=IFERROR(INDEX($A$2:$A$5,SMALL(IF($C$2:$C$5<>0,ROW($A$2:$A$5)-ROW($A$2)+1),ROWS($A$8:A8))),"")
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
You also don't show us what version(s) of Excel you are using.
If you have Excel 365 you could try a formula like this which only needs to be entered in a single cell and the other results will automatically 'spill' across and down to the other required cells.

21 02 18.xlsm
ABCD
1FundTargetTrade
2ABC10
3DEF25
4GHI30
5JKL4-14
6
7
8FundTrade
9DEF50
10JKL-140
11
Extract and Filter
Cell Formulas
RangeFormula
A9:C10A9=FILTER(CHOOSE({1,2,3},A2:A5,C2:C5,D2:D5),C2:C5<>0,"")
Dynamic array formulas.
 
Upvote 0
Sorry about that, have updated my profile, the version is 2016.

Was hoping for a VBA Macro as I need to run daily.

@ Peter_SSs - Column C should equal 0 if A and B are populated as the result gets loaded into a system that requires a zero in the last cell of a result.

I will try those ideas above, thanks very much for your time
 
Upvote 0
Sorry about that, have updated my profile, the version is 2016.
Thanks for that. (y)

Was hoping for a VBA Macro
Good idea to state that in your opening post. ;)
Try this with a copy of your data. I have assumed headings in row 1 with actual data starting in row 2. Code puts results in columns E:G.

VBA Code:
Sub ExtractAndFilter()
  Dim a As Variant, b As Variant
  Dim i As Long, k As Long
  
  a = Range("A2", Range("C" & Rows.Count).End(xlUp)).Value
  ReDim b(1 To UBound(a), 1 To 3)
  For i = 1 To UBound(a)
    If a(i, 3) <> 0 Then
      k = k + 1
      b(k, 1) = a(i, 1)
      b(k, 2) = a(i, 3)
      b(k, 3) = 0
    End If
  Next i
  If k > 0 Then
    With Range("E2:G2").Resize(k)
      .Value = b
      .Rows(0).Value = Array("Fund", "Trade", "???")
      .EntireColumn.AutoFit
    End With
  End If
End Sub

My sample data and results

21 02 18.xlsm
ABCDEFG
1FundTargetTradeFundTrade???
2ABC10DEF50
3DEF25JKL-140
4GHI30
5JKL4-14
6
Extract and Filter (2)
 
Upvote 0
Solution
Brilliant thanks very much Peter_SSs works perfectly.

I will investigate more on the use of the UBound function (y)
 
Upvote 0
You're welcome. Thanks for the follow-up. :)
 
Upvote 0

Forum statistics

Threads
1,214,648
Messages
6,120,726
Members
448,987
Latest member
marion_davis

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