Wallenbees
Wallenbees

Reputation: 83

Setting Cell Value as Formula

Could someone tell me what I am doing wrong with this sytax?

Worksheets("LTXN Report").Range("A2").Formula = "=""####-#""&IF(Launch!C7<>,RIGHT(Launch!,LEN(Launch!C7)-5),IF(Launch!C15<>,RIGHT(Launch!C15<>,LEN(Launch!C15)-5),IF(Launch!C23<>,RIGHT(Launch!C23,LEN(Launch!C23)-5),)))"

Essentially what I am doing is setting a clear function that copies a back up version of my sheets and replaces the previous version. However, on my launch worksheet, there are three options to search by (represented by cells C7, C15, and C23). The spreadsheet will pull transaction data and then filter it into a report, and I am trying to have this formula be filled out in the A2 cell of the new report when the new page is created.

I keep getting an object error. It seems like it doesnt like me using #'s or *'s to mask the account number in the function. Any ideas on how I could still do this?

Upvotes: 1

Views: 89

Answers (1)

Wallenbees
Wallenbees

Reputation: 83

I got it here. I simply had the quotes incorrect.

Worksheets("LTXN Report").Range("A2").Formula = "=""****-*""&IF(Launch!C7 <> """",RIGHT(Launch!C7,LEN(Launch!C7)-5),IF(Launch!C15 <> """",RIGHT(Launch!C15,LEN(Launch!C15)-5),IF(Launch!C23 <> """",RIGHT(Launch!C23,LEN(Launch!C23)-5),"""")))"

works!

Upvotes: 1

Related Questions