![]() |
Improvement to code
The below works, but can it be more efficient?
What I'm doing is on a daily basis copy the equations over a column, range "value", "Yesterday" results (so those results don't change) and then bring in the new daily data. if nothing else I think that I should remove the 5 and 33 with range names... Sub DAILY() Dim LastCol As Long With Sheets("WeeksDetail") LastCol = .Cells(5, Columns.Count).End(xlToLeft).Column .Cells(5, LastCol).Resize(33, 1).Copy .Cells(5, LastCol + 1) .Cells(5, LastCol).Resize(33, 1).Value = .Cells(5, LastCol).Resize(33, 1).Value End With ActiveWorkbook.RefreshAll End Sub |
Improvement to code
assuming your table always has data in row 5
how's this? With Columns(Range("IV5").End(xlToLeft).Column) Columns(.Column + 1).Formula = .Formula .Value = .Value End With "Brad" wrote: The below works, but can it be more efficient? What I'm doing is on a daily basis copy the equations over a column, range "value", "Yesterday" results (so those results don't change) and then bring in the new daily data. if nothing else I think that I should remove the 5 and 33 with range names... Sub DAILY() Dim LastCol As Long With Sheets("WeeksDetail") LastCol = .Cells(5, Columns.Count).End(xlToLeft).Column .Cells(5, LastCol).Resize(33, 1).Copy .Cells(5, LastCol + 1) .Cells(5, LastCol).Resize(33, 1).Value = .Cells(5, LastCol).Resize(33, 1).Value End With ActiveWorkbook.RefreshAll End Sub |
Improvement to code
I wouldn't change a thing... Your code is efficient as it is. You could
change the 5 and the 33 to declared constants which will make updating the code easier if things change but otherwise it is very reasonable. -- HTH... Jim Thomlinson "Brad" wrote: The below works, but can it be more efficient? What I'm doing is on a daily basis copy the equations over a column, range "value", "Yesterday" results (so those results don't change) and then bring in the new daily data. if nothing else I think that I should remove the 5 and 33 with range names... Sub DAILY() Dim LastCol As Long With Sheets("WeeksDetail") LastCol = .Cells(5, Columns.Count).End(xlToLeft).Column .Cells(5, LastCol).Resize(33, 1).Copy .Cells(5, LastCol + 1) .Cells(5, LastCol).Resize(33, 1).Value = .Cells(5, LastCol).Resize(33, 1).Value End With ActiveWorkbook.RefreshAll End Sub |
All times are GMT +1. The time now is 10:08 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com