MARK858
MrExcel MVP
- Joined
- Nov 12, 2010
- Messages
- 16,820
- Office Version
- 365
- Platform
- Windows
- Mobile
Is there some way the code below can be re-written into a single piece of code so it can be added to the end of another macro.
Basically the other code opens a text file, so it opens another workbook with the text files name and this code needs to run on that workbook.
Everything I have tried so far causes the macro's below to run on the first empty workbook.
Looking for any guidance please .
Basically the other code opens a text file, so it opens another workbook with the text files name and this code needs to run on that workbook.
Everything I have tried so far causes the macro's below to run on the first empty workbook.
Looking for any guidance please .
Code:
Sub addFormula()
Dim LastRow As Long
With Sheet1
LastRow = .UsedRange.Rows.Count
.Range(.Cells(2, 14), .Cells(LastRow, 14)).Formula = _
"=VLOOKUP(E2,Sheet2!A:H,8,1)"
End With
End Sub
Sub addFormula3()
Dim LastRow As Long
With Sheet1
LastRow = .UsedRange.Rows.Count
.Range(.Cells(2, 16), .Cells(LastRow, 16)).FormulaR1C1 = _
"=IF(RC[-2]>RC[-1],""OVER CAPACITY"","""")"
End With
End Sub
Sub addFormula2()
Dim LastRow As Long
With Sheet1
LastRow = .UsedRange.Rows.Count
.Range(.Cells(2, 15), .Cells(LastRow, 15)).Formula = _
"=VLOOKUP(E2,Sheet3!A:M,11,1)"
End With
End Sub
Sub addFormula5()
Dim LastRow As Long
With Sheet1
LastRow = .UsedRange.Rows.Count
.Range(.Cells(2, 17), .Cells(LastRow, 17)).FormulaR1C1 = _
"=IF(RC[-2]<=3,""CAP NOT SET"","" "")"
End With
End Sub