Trying to create formula w/ web address in VB

boznian

Board Regular
Joined
Mar 25, 2003
Messages
167
Using the following code to try and create a concatenated formula in VB so that I end up with a useable web address. I cannot get it to work and keep getting a "Type MisMatch" error:

Code:
        crow = ActiveCell.Row
        Cells(crow, "D:D").Select
        ActiveCell.FormulaR1C1 = "=SUBSTITUTE(RC[-1], "" "",""-"")"
        Cells(crow, "B:B").Select
        ActiveCell.FormulaR1C1 = "=CONCATENATE(""http://www.webaddresshere.com/"",(crow, ""D:D"")," / ")"

The "substitute" formula works fine, why not the web address? I need to pull in the value in column D from the current row - am I going about it the wrong way?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Code:
ActiveCell.FormulaR1C1 = "=CONCATENATE(""http://www.webaddresshere.com/"",(crow, ""D:D"")," / ")"
Assuming crow evaluates to 9, show us what you think this formula should look like when placed in the cell.
 
Upvote 0
Give this a try...

ActiveCell.Formula = "=CONCATENATE(""http;//www.webaddress.com/"",D" & crow & ",""/"")"

Also note I am using the Formula property (because of the eventual D9 reference) instead of the FormulaR1C1 property (which expects the formula to be using R1C1 notation).
 
Upvote 0
Man, I am really awful at this. I really thought the next step would be easy once you gave me the previous answer, but now I can't get this to work either:

All I need now is to end up with the formula =LOWER(D32) where the "32" is determined by crow again. Tried every variatio of
Code:
         ActiveCell.Formula = "=LOWER(""D"", crowt)"
I can think of...
 
Upvote 0
Man, I am really awful at this. I really thought the next step would be easy once you gave me the previous answer, but now I can't get this to work either:

All I need now is to end up with the formula =LOWER(D32) where the "32" is determined by crow again. Tried every variatio of
Code:
         ActiveCell.Formula = "=LOWER(""D"", crowt)"
I can think of...
The thing to keep in mind is what you are after is a text string, so basically you just have to concatenate the parts you want together... and remember that variables cannot be inside the quote marks. Since this is a simple formula, let me show you how my thinking went. You start with this...

=LOWER(D32)

make it a text string...

"=LOWER(D32)"

separate the part that will be supplied by the variable crow...

"=LOWER(D" & 32 & ")"

and replace the number with the variable...

"=LOWER(D" & crow & ")"

Now put that together with the formula assignment statement..

Code:
ActiveCell.Formula = "=LOWER(D" & crow & ")"
 
Upvote 0
Hey Rick-

Just wanted to say thanks again, and especially thanks for taking the time to explain it to me - now I get it!!

This is a wonderful place...
 
Upvote 0

Forum statistics

Threads
1,224,811
Messages
6,181,082
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top