user7700302
user7700302

Reputation: 11

How to create a formula with variables and string on excel?

I want this line:

./command.sh -id IDVAL -amount MONEY -assignment SIGNVAL -reason "goodjob"

as a formula in excel. IDVAL is in cell A2, MONEY is in B2, SIGNVAL is in C2 (for the first line.. for the second line, IDVAL is in A3, MONEY in B3 etc.).

To make this a formula, what I tried was

./command.sh -id =A2 -amount =B2 -assignment =C2 -reason "goodjob"

but it recognizes =A2 as a string (doesn't read what is in A2). How would I get it to read what is in the A2 cell rather than having it as a string?

Edit: I copy pasted this into the cell / "fx" bar near the top of excel. I also tried

./command.sh -id =evaluate(=A2)

but that doesn't work either.

Upvotes: 0

Views: 81

Answers (1)

Marc
Marc

Reputation: 11633

Concatenate strings using ampersand &:

="./command.sh -id "&A2&" -amount "&B2&" -assignment "&C2&" -reason "&CHAR(34)&"goodjob"&CHAR(34)

I often use CHAR(34) as the double-quote character.

But you can also escape the double quotes around "goodjob" by doubling them like this:

="./command.sh -id "&A2&" -amount "&B2&" -assignment "&C2&" -reason ""goodjob"""

Upvotes: 3

Related Questions