title: Creating a hyperlink containing variables
body: <p>I'm still pretty new to VBA but i'm trying to get a macro to add a hyperlink based on information stored in a spreadsheet.</p>
  
  <p>So, for example, the link would look something like this (where by the variable parts of the links are listed as VARIABLE:</p>
  
  <pre><code>www.example.com/VARIABLE1&amp;Diff=300&amp;Start=0000VARIABLE2&amp;End=2359VARIABLE3
  </code></pre>
  
  <p>I have already worked out these variables in my excel spreadsheet using a previous macro:</p>
  
  <p>VARIABLE1: This variable is stored in column H, it is an individual variable for each row.</p>
  
  <p>VARIABLE2: This variable is stored in Q8. this is the same for each row, the number is worked out in a previous macro but is the same for every row in the document</p>
  
  <p>VARIABLE3: This variable is stored in R8. this is the same for each row, the number is worked out in a previous macro but is the same for every row in the document</p>
  
  <p>So far i have the following code, but i'm having no luck. It either includes the variable name as text inside the formula in excel, rather than what is stored in the variable or it doesn't work at all. I've tried various ways but no luck:</p>
  
  <pre><code>Dim Variable2 As Long
  
  Dim Variable3 As Long
  
  Variable2 = range("Q8").Value
  
  Variable3 = range("R8").Value
  
  range("E2").FormulaR1C1 = "=HYPERLINK(""https://www.example.com"" &amp; RC[3] &amp; ""&amp;Diff=300&amp;Start=0000"" &amp; Variable2 &amp; ""&amp;End=2359"" &amp; Variable 3)"
  </code></pre>
  
  <p>This formula then needs to be copied down all the way down column 'E' to the last row of data to create a hyperlink for each row of the spreadsheet.</p>
  
  <p>Any help / guidance will be greatly appreciated.</p>
  
  <p>Thanks in advance.</p>