2

No doubt the solution is probably right under my nose, but after spending hours messing with this I give up. I have a workaround which is not acceptable. Here is the formula straight out of the spreadsheet:

="https://www.google.com/maps/?z=12&t=k&q="&D2&"'"&C2

Here is the VBA code for which I get errors whatever I seem to do with it.

 ActiveCell.FormulaR1C1 = "="""https://www.google.com/maps/?z=12&t=k&q="""&D2&"" '""&C2"

I would surely appreciate it if someone could help. I don't normally have too much difficulty with concatenation, but, this one has got me and there is no doubt some simple trick I am overlooking. Thanks in advance.

2
  • The & string concatenation operator in Excel formulas can be used like this (without spaces), but be careful in VBA code; make sure to precede it with a space, otherwise FooBar& gets interpreted as a type hint for a Long identifier, as 42& gets interpreted as a type hint for a Long literal. Commented Jul 14, 2017 at 15:04
  • I will take a look at that and keep that in mind. Thanks a lot for your input! Commented Jul 14, 2017 at 15:17

1 Answer 1

3

You want .Formula when dealing with A1 notation.

And only "" on each end of the website string.

use this:

ActiveCell.Formula = "=""https://www.google.com/maps/?z=12&t=k&q=""&D2&""'""&C2"
Sign up to request clarification or add additional context in comments.

1 Comment

That did it! It seems to me that it can be unnecessarily difficult at times. If they were able to send a man to the moon... Thanks for saving a lot more time!! Will vote it up as soon as I'm eligible...

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.