How to save only the rows that contain a value and ignore blank rows

ubergreen

New Member
Joined
Jun 13, 2024
Messages
33
Office Version
  1. 2021
I actually don't even know how to phrase this question properly, so if anything is confusion or require clarification, let me know.

I basically have a power query file that compiles all of my orders. I want to keep track of what orders have paid already and which ones have not paid yet.

The ones that have paid already will have an amount next to their order #.

I want to be able to save the file with only the orders that have been paid and the orders that do not have an amount next to them (not paid) to remain in the file.

So for example, Example 1 is the initial starting file, which has amounts next to Order # 1, 2, 3, and 5. I then want to be able to save only just those rows as a CSV file. The remaining rows, # 4 and 6, which do not have amounts next to them, will remain and stay in that file until they have been paid.

I was thinking I could create a table for the amount column and then simply uncheck the boxes for blank/not blank cells in that column, but the issue with that is I do not want the old rows that were previously already paid to be displayed when I go to save the new CSV file.


I only want to be able to continuously only save the new rows that have been paid/amount next to the order #.


1723658329913.png
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
VBA Code:
Option Explicit

Sub TransferPaid()
    Dim lR As Long, lC As Long
    Dim vOut As Variant, vIn As Variant
    Dim wsOut As Worksheet, wsIn As Worksheet
    Dim rIn As Range
    
    Set wsIn = Sheets("Sheet1")                 '<<<<  Modify sheet name to the sheet where the power query drops the table
    Set rIn = wsIn.Range("A3").CurrentRegion    '<<<<  Modify range cell to top left cell of power query table
    
    vIn = rIn.Value
    ReDim vOut(1 To UBound(vIn, 1), 1 To UBound(vIn, 2))
    
    For lR = 1 To UBound(vIn, 1)
        If vIn(lR, 2) <> 0 Then
            For lC = 1 To UBound(vIn, 2)
                    vOut(lR, lC) = lin(lR, lC)
            Next lC
        End If
    Next lR
    
    Sheets.Add
    Set wsOut = ActiveSheet
    
    wsOut.Range("A3").Resize(lR - 1, lC - 1).Value = vOut
    
    Save2CSV wsOut
    
    wsOut.Delete
    
End Sub


Sub Save2CSV(ws2Save As Worksheet)
  Application.ScreenUpdating = False
  Application.DisplayAlerts = False
  ws2Save.Copy
  ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "\" & "FileName.csv", FileFormat:=xlCSV   '<<< modify path for .CSV as required
  ActiveWorkbook.Close False
End Sub
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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