Excel VBA export from Pivot table

shophoney

Active Member
Joined
Jun 16, 2014
Messages
281
Hi,

I have a pivot table based on data and need to run VBA to format for export to QuickBooks.

Below is the table and I need the data from the table on one line with the "j" column for the TRNS line, excluding "i" column.

And the same info but with not the "j" but "i" column leaving out "j".
1671845013669.png


This is the end result I want:
1671845625890.png


I want to copy and shift the data to a new tab to be exported for QuickBooks.



This is the CODE i have to start with.

Sub Quickbooks_Import()
Dim ws As Worksheet
Dim rng As Range

Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy

Set ws = Worksheets.Add(after:=Sheets("QB Import"))
ws.Name = "QB iif " & Format(Date, "mm_dd_yy") & "@" & Format(Time, "hhmm")


Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Application.CutCopyMode = False

Application.GoTo Reference:="R1C1"
Rows("3:3").Select
Selection.Delete Shift:=xlUp

Call InsertOwnersDraw
Call InsertENDTRNS

ChDir "D:\Dropbox\FaceUp Innovations Consulting Inc\Import"
ActiveWorkbook.SaveAs Filename:= _
"D:\Dropbox\FaceUp Innovations Consulting Inc\Import\Export.iif" & Format(Date, "mm_dd_yy") & "@" & Format(Time, "hhmm"), FileFormat:=xlText, _
CreateBackup:=False
End Sub

Sub InsertOwnersDraw()

Dim export As Worksheet
Dim UnnecessaryRow As Range
Dim TRNS_ROW As Range

Set TRNS_ROW = Range("A4")

While TRNS_ROW.Value <> ""

If TRNS_ROW.Value = "TRNS" And TRNS_ROW.Offset(-1, 0) <> "SPL" Then

TRNS_ROW.EntireRow.Insert

TRNS_ROW.Offset(-1, 0) = "SPL"

End If

If TRNS_ROW.Value = "SPL" And TRNS_ROW.Offset(1, 0) = "" Then

TRNS_ROW.Offset(1, 0) = "SPL"

End If

Set TRNS_ROW = TRNS_ROW.Offset(1)

Wend

End Sub

Sub InsertENDTRNS()

Dim export As Worksheet
Dim UnnecessaryRow As Range
Dim TRNS_ROW As Range

'Set UnnecessaryRow = Range("A3")

'UnnecessaryRow.EntireRow.Delete

Set TRNS_ROW = Range("A4")

While TRNS_ROW.Value <> ""

If TRNS_ROW.Value = "TRNS" And TRNS_ROW.Offset(-1, 0) <> "ENDTRNS" Then

TRNS_ROW.EntireRow.Insert

TRNS_ROW.Offset(-1, 0) = "ENDTRNS"

End If

If TRNS_ROW.Value = "SPL" And TRNS_ROW.Offset(1, 0) = "" Then

TRNS_ROW.Offset(1, 0) = "ENDTRNS"

End If

Set TRNS_ROW = TRNS_ROW.Offset(1)

Wend

End Sub




Hope this makes sense, thanks
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

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