Run-time error '1004'

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,558
I can't figure out how to get rid of the Run-time error '1004':

My VBA code is supposed to write a simple ISERROR-function to the worksheet. When I type it manually and record a macro the code reads:
Code:
ActiveCell.FormulaR1C1 = _
        "=IF(ISERROR(VLOOKUP(VALUE(E2),Pnro,5)),"""",VLOOKUP(E2),Pnro,5))"
But when I try to make the code type the same function or run the recorded code I'm getting "Run-time error '1004' - Application-defined or object-defined error".

I thought I might be missing a reference so I tried adding the atpvbaen.xls just in case but it didn't help.

How do I get rid of the error?
 

MickG

MrExcel MVP
Joined
Jan 9, 2008
Messages
14,841
Perhaps:-
Code:
ActiveCell.FormulaR1C1 = _
        "=IF(ISERROR(VLOOKUP(E2,Pnro,5)),"""",VLOOKUP(E2,Pnro,5))"
 

Misca

Well-known Member
Joined
Aug 12, 2009
Messages
1,558
Thanks!

A typo never even crossed my mind: I was positive I had not touched the recorded code but looks like I had.
 

eyong123

New Member
Joined
Aug 1, 2011
Messages
34
Hi Gurus,

i have a similar problem with run time error 1004 and pastespecial method of range class failed Here are my codes. Please I need you help to overcome this

thanks in advance


Sub transfer_data_to_week_report()

'transfer data from week dashboard to previous week report file



Range("A153").Select
Datez = ActiveCell
'
'yearz
'
yearz = Right(Year(Datez), 2)

'
'Numéro de Mois
'

'Numéro de Semaine
'
numSem = DatePart("ww", Datez)
indexSem = numSem - 1
'
'Numéro du Jour
'
numJour = Day(Datez)

'



Range("A20:K149").Select
Selection.Copy



Workbooks.Open Filename:= _
"E:\WR" & yearz & "_" & indexSem & ".xls"


ActiveWorkbook.Sheets("Verl F1&2").Activate


Range("U5").Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


ActiveWorkbook.Close True


End Sub
 

Forum statistics

Threads
1,082,549
Messages
5,366,237
Members
400,881
Latest member
aforte

Some videos you may like

This Week's Hot Topics

Top