1

I have a question regarding string modification. Let's assume that we have the following string: 4155595208***
in cell A1 (10 numbers and 3 starts).

Now I would like to substitute these 3 stars with a blank field and get the result in cell B1 (so I want 4155595208 to get as a result). If I used a normal built-in Excel function I would type the following thing into cell B1:
=SUBSTITUTE(A1,"*","")

Now I would like to do the very same thing using Excel VBA. Whenever I tried to run the following code however, I got the error message: "Run-time error '13': Type mismatch".

sub test()
cells(1,2) = "=SUBSTITUTE(M2," * ","")"
end sub

I guess the problem might occur because of the bunch of quotation marks but I don't know. Could someone help me with this matter?

Thanks in advance,
Laszlo

1 Answer 1

1

You need to use double double quotes when writing formulas

Cells(1, 2) = "=SUBSTITUTE(M2,"" * "","""")"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.