Hi All,
I have a 8 macros I use every morning which simply select the last used column and copies the data into the next available column:
and the below is another example:
There are seven other varieties of this in different workbooks which essentially does the same thing (see the code above, some are for multiple worksheets). I've assigned all of these macros a shortcut (ctrl+q) however if I have two spreadsheets open the macro fails as it looks for the wrong spreadsheet.
Is there a way I can put all of these macros together in one sub and have the code look up the active workbook name, then run a set piece of the code?
Thanks!
I have a 8 macros I use every morning which simply select the last used column and copies the data into the next available column:
Code:
Sheets("PL").Activate
Dim i As Long
i = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(i).Copy Destination:=Cells(1, i + 1)
With Cells(1, i + 1)
.Formula = "=WORKDAY(NOW(),-1)"
.Value = .Value
End With
End Sub
and the below is another example:
Code:
ActiveWorkbook.Sheets("EUR").Activate
Dim i As Long
i = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(i).Copy Destination:=Cells(1, i + 1)
With Cells(1, i + 1)
.Formula = "=WORKDAY(NOW(),-1)"
.Value = .Value
End With
Sheets("GBP").Activate
i = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(i).Copy Destination:=Cells(1, i + 1)
With Cells(1, i + 1)
.Formula = "=WORKDAY(NOW(),-1)"
.Value = .Value
End With
Sheets("NOK").Activate
i = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(i).Copy Destination:=Cells(1, i + 1)
With Cells(1, i + 1)
.Formula = "=WORKDAY(NOW(),-1)"
.Value = .Value
End With
Sheets("USD").Activate
i = Cells(1, Columns.Count).End(xlToLeft).Column
Columns(i).Copy Destination:=Cells(1, i + 1)
With Cells(1, i + 1)
.Formula = "=WORKDAY(NOW(),-1)"
.Value = .Value
End With
Sheets("EUR").Activate
End Sub
There are seven other varieties of this in different workbooks which essentially does the same thing (see the code above, some are for multiple worksheets). I've assigned all of these macros a shortcut (ctrl+q) however if I have two spreadsheets open the macro fails as it looks for the wrong spreadsheet.
Is there a way I can put all of these macros together in one sub and have the code look up the active workbook name, then run a set piece of the code?
Thanks!