#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 23
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 563
Default 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


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 50
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:03 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"