Hi,
Newbie I have the below and get an error. Any idea ? thanks
"compile error"- "duplicate declaration in current scope"? For lastRow As Long as per debugger.
Newbie I have the below and get an error. Any idea ? thanks
"compile error"- "duplicate declaration in current scope"? For lastRow As Long as per debugger.
Rich (BB code):
Sub Insert_formula_TOTAL()
With Sheets("GBP")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("NZD")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("SEK")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("EUR")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("CAD")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("USD")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("DKK")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("JPY")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("AUD")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("CHF")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
With Sheets("NOK")
.Range("AC2").Formula = "=IF(ISNUMBER(SEARCH(""TOTAL"",B2)),O2,"""")"
Dim lastRow As Long
lastRow = .Range("O" & Rows.Count).End(xlUp).Row
.Range("AC2").AutoFill Destination:=.Range("AC2:AC" & lastRow)
End With
End Sub