title: Getting around the Max String size in a vba function?
body: <p>The max number of characters you can use in string in a vba function is 255. 
  I am trying to run this function</p>
  
  <pre><code>Var1= 1
  Var2= 2
  .
  .
  .
  Var256 =256
  
  RunMacros= "'Tims_pet_Robot """ &amp; Var1 &amp; """ , """ &amp; Var2 &amp; """ , """   ... """ &amp; Var256 """ '"
  Runat=TimeValue("15:00:00")
  Application.OnTime EarliestTime:=Runat, Procedure:=RunMacros &amp; RunMacros2 ', schedule:=True
  </code></pre>
  
  <p>It runs a procedure at a certain time and passes a bunch of variables to it. but the string is too long.</p>
  
  <p>Update: 
  Regrettably I am sure it is not the watch window.
  Also, it isn't really the max size of a string that I'm dealing with. It's the max size of 
  a string in a vba function.</p>
  
  <p>For example this function works.</p>
  
  <pre><code>Sub test()
  Dim RunAt As Date
  Dim RunWhat As String
  
  RunAt = Now + 0.00001
  RunWhat = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" &amp; _
  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" &amp; _
  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 'that makes 254 'a''s
  Application.OnTime EarliestTime:=RunAt, Procedure:="'" &amp; RunWhat &amp; " 12'"
  
  End Sub
  
  
  Sub aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(m As Integer)
  MsgBox ("it works!" &amp; m)
  End Sub
  </code></pre>
  
  <p>But if you change the 12 to 123 it breaks
  Example</p>
  
  <pre><code>Sub test2()
  Dim RunAt As Date
  Dim RunWhat As String
  
  RunAt = Now + 0.00001
  RunWhat = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" &amp; _
  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" &amp; _
  "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 'that makes 254 'a''s
  Application.OnTime EarliestTime:=RunAt, Procedure:="'" &amp; RunWhat &amp; " 123'"
  
  End Sub
  
  
  Sub aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(m As Integer)
  MsgBox ("it works!" &amp; m)
  End Sub
  </code></pre>
  
  <p>This code does not work, I'm pretty sure it's because a vba function cannot handle a string with more than 255 chars. 
  Even if you're in Excel and call a function and give it a string longer that 255 chars it doesn't work. </p>
  
  <p>Try in cell A1 =vlookup("really long string", A1:Z10, 1) and then put the really long string somewhere in that range. The vlookup will fail (not fail to find it, but you won't actually be able to do it)</p>
  
  <p>Also I am aware that there is a max length to a sub name, I'm just under it. Sorry that it look so ugly.</p>
  
  <p>Update 2: so I just ended up printing the variable to a sheet and getting the function called by ontime to read them off the sheet. :(</p>