title: I'd like to run a loop, but change 2 variables each instance
body: <p>I am trying to edit a VBA code.  I customized it for my needs, but it is currently repeating the same process over 20 times, and I have basically entered the code 20 times and changed the variables.  </p>
  
  <p>I will likely have up to 100 instances, and don't want to manually do this.  How can I edit this code so that it runs 100 times while changing the variables?</p>
  
  <p>As you see, I have included the same code twice with slight changes.  I would need to change the ticker and range for each iteration, and Also, the destination Range would need to move 1 column over each time.</p>
  
  <p>By the way, this is for pulling yahoo finance stock info.</p>
  
  <pre><code>Sub Data_Get()
  '
  ' Data_Get Macro
  '
  Dim ticker1, ticker2, ticker3 As String, sday, smonth, syear, eday, emonth, eyear As Long
  
  ticker1 = Range("L1")
  ticker2 = Range("L2")
  ticker3 = Range("L3")
  
  sday = Day(Range("L4"))
  smonth = Month(Range("L4")) - 1
  syear = Year(Range("L4"))
  eday = Day(Range("L5"))
  emonth = Month(Range("L5")) - 1
  eyear = Year(Range("L5"))
  
  '
  With ActiveSheet.QueryTables.Add(Connection:= _
      "TEXT;http://real-chart.finance.yahoo.com/table.csv?s=" &amp; ticker1 &amp; "&amp;d=" &amp; emonth &amp; "&amp;e=" &amp; eday &amp; "&amp;f=" &amp; eyear &amp; "&amp;g=d&amp;a=" &amp; smonth &amp; "&amp;b=" &amp; sday &amp; "&amp;c=" &amp; syear &amp; "&amp;ignore=.csv" _
      , Destination:=Range("$A$1"))
      .Name = "data"
      .FieldNames = True
      .RowNumbers = False
      .FillAdjacentFormulas = False
      .PreserveFormatting = True
      .RefreshOnFileOpen = False
      .RefreshStyle = xlInsertDeleteCells
      .SavePassword = False
      .SaveData = True
      .AdjustColumnWidth = True
      .RefreshPeriod = 0
      .TextFilePromptOnRefresh = False
      .TextFilePlatform = 437
      .TextFileStartRow = 1
      .TextFileParseType = xlDelimited
      .TextFileTextQualifier = xlTextQualifierDoubleQuote
      .TextFileConsecutiveDelimiter = True
      .TextFileTabDelimiter = True
      .TextFileSemicolonDelimiter = False
      .TextFileCommaDelimiter = True
      .TextFileSpaceDelimiter = False
      .TextFileColumnDataTypes = Array(5, 9, 9, 9, 9, 9, 1)
      .TextFileTrailingMinusNumbers = True
      .Refresh BackgroundQuery:=False
  End With
  
  With ActiveSheet.QueryTables.Add(Connection:= _
      "TEXT;http://real-chart.finance.yahoo.com/table.csv?s=" &amp; ticker2 &amp; "&amp;d=" &amp; emonth &amp; "&amp;e=" &amp; eday &amp; "&amp;f=" &amp; eyear &amp; "&amp;g=d&amp;a=" &amp; smonth &amp; "&amp;b=" &amp; sday &amp; "&amp;c=" &amp; syear &amp; "&amp;ignore=.csv" _
      , Destination:=Range("$C$1"))
      .Name = "data2"
      .FieldNames = True
      .RowNumbers = False
      .FillAdjacentFormulas = False
      .PreserveFormatting = True
      .RefreshOnFileOpen = False
      .RefreshStyle = xlInsertDeleteCells
      .SavePassword = False
      .SaveData = True
      .AdjustColumnWidth = True
      .RefreshPeriod = 0
      .TextFilePromptOnRefresh = False
      .TextFilePlatform = 437
      .TextFileStartRow = 1
      .TextFileParseType = xlDelimited
      .TextFileTextQualifier = xlTextQualifierDoubleQuote
      .TextFileConsecutiveDelimiter = True
      .TextFileTabDelimiter = True
      .TextFileSemicolonDelimiter = False
      .TextFileCommaDelimiter = True
      .TextFileSpaceDelimiter = False
      .TextFileColumnDataTypes = Array(9, 9, 9, 9, 9, 9, 1)
      .TextFileTrailingMinusNumbers = True
      .Refresh BackgroundQuery:=False
  End With
  End Sub
  </code></pre>