I have VBA in Access that exports data to Excel into separate sheets. The data comes in unformatted so I am going to create a macro that will format it. The export is inventory data (price of an item and quantity on hand) for multiple locations. The autofill will be a calculation of price*quantity autofilled to the end of the data. The locations do no have the same amount of data in their sheets; I originally tried grouping all the sheets together and just autofilling the first sheet. This did not work. Can anyone direct me to the proper way to do this using a macro or VBA?
Note: The amount of data may change when a new inventory count comes in so the code cannot reference a specific cell in each sheet as the last row.
Thanks for you help!
This uses column F for the products. Select each sheet and run this macro:
Sub dural()
Dim i As Long, N As Long
N = Cells(Rows.Count, "D").End(xlUp).Row
For i = 1 To N
Cells(i, "F") = Cells(i, "D") * Cells(i, "E")
Next i
End Sub
For example:
EDIT#1:
Now that dural()
is working, we can call it from:
Sub MAIN()
Dim i As Long
For i = 3 To Sheets.Count
Sheets(i).Activate
Call dural
Next i
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.