Copying strings and using counters
Hello,
Several ways you could do that. Based on what you mention, first
thought that comes to mind:
Public Sub myBuild()
Dim StringReference as String
Dim StartNumber as Integer
Dim Count as Integer
Dim Iter as Integer
Dim myRange as Range
' Let A1 be the string ABC123
' Let A2 be the start number
' Let A3 be the count
Set myRange = Cells(Range("A4").row, Range("A4").Column)
StringReference = Range("A1").text
StartNumber = Range("A2").value
Count = Range("A3").Value
For Iter = StartNumber to StartNumber + Count
myRange.value = StringReference & " " & Iter
Set myRange = myRange.Offset(1, 0)
Next Iter
' Stuffs the output into Column A, starting at row 4.
End Sub
Is that what you have in mind ?
Chad
" wrote:
Here is what I am trying to do.
I have a spreadsheet with 3 values; a text string ("ABC123"), the first
number in a counter ("100") and a number ("10"). The number is the
number of line-items I need, the text string need to be the same on
each line and the count needs to be incremented by one for each line.
So basically I am trying to come up with a macro that will have the
following output.
ABC123 100
ABC123 101
ABC123 102
ABC123 103
ABC123 104
ABC123 105
ABC123 106
ABC123 107
ABC123 108
ABC123 109
Any ideas on how this would be accomplished?
|