0
votes

I currently have a Macro in Access that will pull in specific CSV files. I am looking to attach VBA code to this macro to also generate a calculated field at the end.

I am able to add the calculated field manually with the expression:

IIf([Weight] <= 5, 1, IIf([Weight] <= 10, 2, IIf([Weight] <= 20, 3, IIf([Weight] <= 30, 4, IIf([Weight] <= 50, 5, 6)))))

Is there a way to add this calculated field automatically when the macro is run, or via a second macro?

This Access database is just being used to connect to Excel and generate PivotTables from the data. I can create the calculated fields within Excel, but cannot use calculated fields as rows in Pivottables.

1

1 Answers

1
votes

You could add this field to a Query then base your Pivots on the Query.