简体   繁体   中英

VBA Runtime Error '1004' when attempting to Insert Formula

I've figured out how to insert a formula into a range of cells and managed to make it work once. Unfortunately, I can't get it to work with this formula. Instead I get an

Application-defined or object-defined error.

Here's what I'm attempting to run.

Sheets("P&L").Select
Range("A1:A250").Select
Selection.FormulaR1C1 = "=IF(ISNUMBER(LEFT(RC[+1],4)*1),LEFT(RC[+1]4,4)*1,)"
Selection.Columns.AutoFit

I suspect it has something to do with the * acting as a wildcard. I've put it in block quotes, but that just gives another error.

Any help is appreciated.

您在该公式中额外增加了4个

Selection.FormulaR1C1 = "=IF(ISNUMBER(LEFT(RC[+1],4)*1),LEFT(RC[+1],4)*1, text(,))"

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