rsrasc
11-11-2023, 08:21 AM
Hi all,
Just wondering if the following codes can be combined in one.
Sub Copy_Column_Formulas_025_Budget()
Workbooks("025 FY 2024 Expenses-SSE-Budget.xlsx").Sheets("FY24-Monthly Variance Report").Activate
Dim rng As Range
Dim lastRow As Long
Dim i As Long
On Error GoTo sub_exit
Application.Calculation = xlCalculationManual
Set rng = Range("H2:AE2" & lastRow)
lastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To lastRow
If Cells(i, "F").Value = "Budget" Then
Cells(i, "H").Copy
Cells(i, "I").Resize(, 23).PasteSpecial Paste:=xlPasteFormulas
End If
Next
sub_exit:
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Copy_Column_Formulas_025_Change()
Workbooks("025 FY 2024 Expenses-SSE-Budget.xlsx").Sheets("FY24-Monthly Variance Report").Activate
Dim rng As Range
Dim lastRow As Long
Dim i As Long
On Error GoTo sub_exit
Application.Calculation = xlCalculationManual
Set rng = Range("H2:AE2" & lastRow)
lastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To lastRow
If Cells(i, "F").Value = "% Change" Then
Cells(i, "H").Copy
Cells(i, "I").Resize(, 23).PasteSpecial Paste:=xlPasteFormulas
End If
Next
sub_exit:
Application.Calculation = xlCalculationAutomatic
End Sub
Thanks!
Just wondering if the following codes can be combined in one.
Sub Copy_Column_Formulas_025_Budget()
Workbooks("025 FY 2024 Expenses-SSE-Budget.xlsx").Sheets("FY24-Monthly Variance Report").Activate
Dim rng As Range
Dim lastRow As Long
Dim i As Long
On Error GoTo sub_exit
Application.Calculation = xlCalculationManual
Set rng = Range("H2:AE2" & lastRow)
lastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To lastRow
If Cells(i, "F").Value = "Budget" Then
Cells(i, "H").Copy
Cells(i, "I").Resize(, 23).PasteSpecial Paste:=xlPasteFormulas
End If
Next
sub_exit:
Application.Calculation = xlCalculationAutomatic
End Sub
Sub Copy_Column_Formulas_025_Change()
Workbooks("025 FY 2024 Expenses-SSE-Budget.xlsx").Sheets("FY24-Monthly Variance Report").Activate
Dim rng As Range
Dim lastRow As Long
Dim i As Long
On Error GoTo sub_exit
Application.Calculation = xlCalculationManual
Set rng = Range("H2:AE2" & lastRow)
lastRow = Cells(Rows.Count, "F").End(xlUp).Row
For i = 1 To lastRow
If Cells(i, "F").Value = "% Change" Then
Cells(i, "H").Copy
Cells(i, "I").Resize(, 23).PasteSpecial Paste:=xlPasteFormulas
End If
Next
sub_exit:
Application.Calculation = xlCalculationAutomatic
End Sub
Thanks!