简体   繁体   中英

Why is this VBA giving me a 1004 error

I have tried a few different renditions here are some I THINK should work:

Sheets(Sheet1.Name).Range("Q2").Value = "=IF($H2="""","""",IF($L2=""Successful"",0,IF($O2="""",""Error"",!$O2)))"

Sheets(Sheet1.Name).Range("Q2").Formula = "=IF($H2="""","""",IF($L2=""Successful"",0,IF($O2="""",""Error"",!$O2)))"

Sheets(Sheet1.Name).[Q2].Formula = "=IF($H2="""","""",IF($L2=""Successful"",0,IF($O2="""",""Error"",!$O2)))"

Dim Data As Worksheet
Set Data = ThisWorkbook.Sheets(Sheets1.Name)
Data. (all of the above after the sheets part)

No matter what I do this gives a 1004 error. What am I doing wrong?

It seems to be the "!" before "$O2".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM