I have a system generated report that, when imported into Excel, has financial data in the last used column of each row. However, the last column varies from row to row between columns B and P.
I created a simple macro that gets the job done, but takes a long time when the report get big, because it moves down row by row and does a copy and paste routine.
I'm looking for some faster solution, either VBA or even a formula that I can just copy down. Any ideas?
Here is my existing code:
Thanks
I created a simple macro that gets the job done, but takes a long time when the report get big, because it moves down row by row and does a copy and paste routine.
I'm looking for some faster solution, either VBA or even a formula that I can just copy down. Any ideas?
Here is my existing code:
VBA Code:
Sub GetDataInLastColumn()
'Purpose is to copy the data from the last used column into added column A
Application.ScreenUpdating = False
'Insert a new column A and highlight yellow
Sheets("Copy").Select
MaxRow = ActiveSheet.UsedRange.Rows.Count
Columns("A:A").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Columns("A:A").Interior.Color = 65535
Range("A1").Select
'Find last used column and copy data to column A. Go row by row
Repeat:
If ActiveCell.row > MaxRow Then GoTo Done
Application.StatusBar = "The macro is running please wait...checking row " & ActiveCell.row & " of " & MaxRow
ActiveCell.Offset(rowOffset:=1, columnOffset:=0).Activate
Cells(ActiveCell.row, "XFD").Select
Selection.End(xlToLeft).Select
Cost = ActiveCell.Formula
Cells(ActiveCell.row, "A").Activate
ActiveCell.Formula = Cost
GoTo Repeat
Done:
Application.ScreenUpdating = True
Application.StatusBar = ""
End Sub
Thanks