Hi All, I posted something quite similar a while back.. but since then the requirements have changed.
The macro below takes one long list of values and converts them into 10 digits, adding preceding zeros if needed, then combines them into a comma separated string to use in a query.
I need help adjusting this to split the list inputted in the first column to groups of 1000. My knowledge of Vba isn't good enough, but I think this is quite an easy update to someone who is..
Basically I am hoping it can take the values in column A after the header row, so A2-A1000, execute the macro paste that into B2, then A1001-2001, and execute then paste into B3, etc until the list is finished..
Sub Stringv2()
Dim i, j As Integer
Dim s As String
Dim sPad As String
Const ForceText As String = "'"
tLength = 0
sPad = "0"
i = 1
Do Until Cells(i, 1).Value = ""
s = CStr(Cells(i, 1).Value)
j = 10 - Len(s)
Do Until j <= 0
s = "0" & s
j = j - 1
Loop
Cells(i, 1).Value = ForceText & s
i = i + 1
Loop
i = 1
s = ""
Do Until Cells(i, 1).Value = ""
s = s & Cells(i, 1).Value & ","
i = i + 1
Loop
i = 1
Cells(i, 2).Value = ForceText & s
End Sub
The macro below takes one long list of values and converts them into 10 digits, adding preceding zeros if needed, then combines them into a comma separated string to use in a query.
I need help adjusting this to split the list inputted in the first column to groups of 1000. My knowledge of Vba isn't good enough, but I think this is quite an easy update to someone who is..
Basically I am hoping it can take the values in column A after the header row, so A2-A1000, execute the macro paste that into B2, then A1001-2001, and execute then paste into B3, etc until the list is finished..
Sub Stringv2()
Dim i, j As Integer
Dim s As String
Dim sPad As String
Const ForceText As String = "'"
tLength = 0
sPad = "0"
i = 1
Do Until Cells(i, 1).Value = ""
s = CStr(Cells(i, 1).Value)
j = 10 - Len(s)
Do Until j <= 0
s = "0" & s
j = j - 1
Loop
Cells(i, 1).Value = ForceText & s
i = i + 1
Loop
i = 1
s = ""
Do Until Cells(i, 1).Value = ""
s = s & Cells(i, 1).Value & ","
i = i + 1
Loop
i = 1
Cells(i, 2).Value = ForceText & s
End Sub