Public Sub Demo()
Dim StringVal As String
Dim VariantVal As Variant
VariantVal = "test"
' CONVERT TO STRING <<<<<<<< EXAMPLE HERE <<<<<<<
StringVal = CStr(VariantVal)
End Sub
VariantVal = Worksheets("Sheets1").Range("C2:C" & Sheets("Sheets1").Range("c1000000").End(xlUp).Row).Value
' For c = 2 To Range("C1000000").End(xlUp).Row
' RtnPage = RtnPage & Cells(c, 3) & vbCrLf
' Next c
Set fs = CreateObject("Scripting.FileSystemObject")
Set ah = fs.CreateTextFile("C:\all.txt", True)
ah.Writeline (RtnPage)
ah.Close
You should be able to replace that loop with the following single line of code and it should be much faster...Code:' For c = 2 To Range("C1000000").End(xlUp).Row ' RtnPage = RtnPage & Cells(c, 3) & vbCrLf ' Next c
the loop part is taking forever. help!
[table="width: 500"]
[tr]
[td]RtnPage = Join(Application.Transpose(Range("C2", Cells(Rows.Count, "C").End(xlUp))), vbNewLine)[/td]
[/tr]
[/table]
You are right, of course, I had forgotten about that limit (always limits in Excel... very annoying). Actually, the code line works (no errors), but it only grabs the first 65535 rows of data and ignores any remaining rows.I don't think that will work if there are more than 64K rows.
I removed the strange reply (just thought I'd point it out otherwise someone may think you're being a bit odd!).Edit Note: Just realized I answered an old thread because someone made a strange reply to it today, however I decided to leave my response up as it might prove useful to someone who stumbles across this thread in the future.