title: Excel VBA Copy Cell to another sheet while keeping Hyperlink
body: <p>This is my first post, complete newbie. I have gotten so far by browsing thru this forum. I would be glad if you could provide me with comments to improve that code and make it do what I would like it to do.</p>
  
  <p>I would like to program actions using Excel VBA to do the following: Upon clicking a button, the code would randomly choose a value from a sheet, combine it with a value from an adjacent cell and copy it to another sheet while preserving the hyperlink attached to the first value.
  This is what I have so far:</p>
  
  <pre><code>Sub CommandButton1_Click()
  
     Dim ExNo As Range
     Dim Exercise As Range
     Dim CurrentCell As Range
     Dim RandTemp As Single
     Dim NbEx As Single
  
  Set ExNo = Worksheets("ExList").Range("B3", "B100")
  Set Exercise = Worksheets("ExList").Range("C3", "C100")
  NbEx = WorksheetFunction.CountA(Worksheets("ExList").Range("B3", "B100"))
  For i = 1 To 5    
      RandTemp = Rnd()            
      Set CurrentCell = Worksheets("Exercise").Cells(4 * i, 2)
      CurrentCell = WorksheetFunction.Index(ExNo, Int(NbEx * RandTemp) + 1) &amp; "  " &amp; WorksheetFunction.Index(Exercise, Int(NbEx * RandTemp) + 1)
  
  Next
  
  With ActiveSheet
     .Shapes("CommandButton1").Top = .Range("B25").Top + 4
     .Shapes("CommandButton1").Left = .Range("B25").Left + 4
     .Shapes("CommandButton1").Width = .Range("B25").Width + .Range("C25").Width - 8
  .Shapes("CommandButton1").Height = .Range("B25").Height + .Range("B26").Height - 8
  
  End With
  
  End Sub
  </code></pre>
  
  <p>The values are correctly copied but the hyperlinks are not carried over. 
  Your help is very appreciated.</p>