Good afternoon!
Currently I pull a huge text file from the AS400 monthly and dump it in my project workbook, then format it. I now need to be able to modify the cost field by in VBA using a multiplier.
Currently the AS400 file comes in with 63,289 rows. I run a macro to delete all page, report and column headers and format the result and end up with 58123 rows. At that point the macro places the multiplier in an empty cell, does a copy/paste special/multiply to get the new cost. That portion of the macro has 58123 hard coded. I’d like to be able to feed the number of used rows after formatting to the copy/paste statement as I am certain more items will be added in the future.
The portion of the macro I'm trying to modify is below, with the problem area in red.
I thought perhaps I could define the variable Cnt and pass it to the formula but I either used incorrect syntax or am on the wrong path.
Any suggestions, hints or input are gratefully accepted.
Thanks,
Bill
Currently I pull a huge text file from the AS400 monthly and dump it in my project workbook, then format it. I now need to be able to modify the cost field by in VBA using a multiplier.
Currently the AS400 file comes in with 63,289 rows. I run a macro to delete all page, report and column headers and format the result and end up with 58123 rows. At that point the macro places the multiplier in an empty cell, does a copy/paste special/multiply to get the new cost. That portion of the macro has 58123 hard coded. I’d like to be able to feed the number of used rows after formatting to the copy/paste statement as I am certain more items will be added in the future.
The portion of the macro I'm trying to modify is below, with the problem area in red.
Code:
Worksheets("Item Master").Activate 'make Item Master the active worksheet
Dim Cnt as integer
Cnt = ActiveSheet.UsedRange.Rows.Count
Range("F1") = 1.32 'set multiplier to increase item cost to builder cost
Range("F1").Copy 'copy multiplier
[COLOR=#ff0000][B] Range("C1:C&Cnt")[/B][/COLOR].PasteSpecial xlPasteAll, Operation:=xlMultiply 'paste special/multiply for new cost
ActiveSheet.UsedRange 'Shrink used area down to size of formatted Item Master
I thought perhaps I could define the variable Cnt and pass it to the formula but I either used incorrect syntax or am on the wrong path.
Any suggestions, hints or input are gratefully accepted.
Thanks,
Bill