LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Application Defined Error setting a formula via VBA

The following code is giving me a Application Defined or Object Defined
error trying to set a formula for cell I for each row:

Dim wb As Workbook
Dim ws As Worksheet
Dim res As Variant

Set wb = ActiveWorkbook
Set ws = wb.Worksheets("Data")
Set rng = Cells(Rows.Count, 1).End(xlUp)


For i = rng.Row To 2 Step -1

alias2 = Sheets("Data").Rows(i).Cells(3).Value

ws.Cells(i, "C").Value = Application.VLookup(alias2, _
Sheets("PolicyStatus").Range("A:B"), 2, False)
'The above works

'Below getting error

ws.Cells(i, "I").Formula =
"=IF(AND(RIGHT(H2,3)='001',RIGHT(H2,3)<='275'),'F TA', " & _
"IF(AND(RIGHT(H2,3)='276',RIGHT(H2,3)<='299'),'Sp ecial
Retired',IF(AND(RIGHT(H2,3)='300',RIGHT(H2,3)<='8 99'),'BROKER', " & _
"IF(AND(RIGHT(H2,3)='900',RIGHT(H2,3)<='999'),'FR ','UNASSIGNED'))))"

TIA

 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Runtime error 1004- application defined or object defined error Novice Excel Programming 11 February 6th 06 11:02 PM
Runtime error 1004- application defined or object defined error Jim Thomlinson[_5_] Excel Programming 0 February 6th 06 09:33 PM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
How to set a formula in a cell? Application-defined error. John Wirt[_5_] Excel Programming 6 February 18th 05 02:11 PM
Macro Run-time Error 1004 Application Defined or Object Defined Error Anddmx Excel Programming 6 June 9th 04 03:40 PM


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

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"