ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   end it (https://www.excelbanter.com/excel-discussion-misc-queries/257263-end.html)

stacia

end it
 
It gives me an error on end if


Sub b9shop()

Dim theRange As Range
Dim lastrow&, firstRow&, x&
Worksheets("Payroll").Activate
ActiveSheet.UsedRange.Select
Set theRange = ActiveSheet.UsedRange
lastrow = theRange.Cells(theRange.Cells.Count).Row
firstRow = theRange.Cells(1).Row
For x = lastrow To firstRow Step -1
If InStr(1, Cells(x, 1), "Total") 0 Then
Worksheets("payroll").Active
With ActiveCell.Cells(x + 2, 1)
FormulaR1C1 = _
"=VLOOKUP(Data!R[-5]C:R[410]C[6],Address!R2C1:R21C4,2)"
End If
Next
End Sub


--
Stacia

Bernard Liengme[_2_]

end it
 
Need an End With just before End If
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"stacia" wrote in message
...
It gives me an error on end if


Sub b9shop()

Dim theRange As Range
Dim lastrow&, firstRow&, x&
Worksheets("Payroll").Activate
ActiveSheet.UsedRange.Select
Set theRange = ActiveSheet.UsedRange
lastrow = theRange.Cells(theRange.Cells.Count).Row
firstRow = theRange.Cells(1).Row
For x = lastrow To firstRow Step -1
If InStr(1, Cells(x, 1), "Total") 0 Then
Worksheets("payroll").Active
With ActiveCell.Cells(x + 2, 1)
FormulaR1C1 = _
"=VLOOKUP(Data!R[-5]C:R[410]C[6],Address!R2C1:R21C4,2)"
End If
Next
End Sub


--
Stacia



Allen

end it
 
I believe you need to end the With statement first.

"stacia" wrote:

It gives me an error on end if


Sub b9shop()

Dim theRange As Range
Dim lastrow&, firstRow&, x&
Worksheets("Payroll").Activate
ActiveSheet.UsedRange.Select
Set theRange = ActiveSheet.UsedRange
lastrow = theRange.Cells(theRange.Cells.Count).Row
firstRow = theRange.Cells(1).Row
For x = lastrow To firstRow Step -1
If InStr(1, Cells(x, 1), "Total") 0 Then
Worksheets("payroll").Active
With ActiveCell.Cells(x + 2, 1)
FormulaR1C1 = _
"=VLOOKUP(Data!R[-5]C:R[410]C[6],Address!R2C1:R21C4,2)"
End If
Next
End Sub


--
Stacia



All times are GMT +1. The time now is 01:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com