deanmoakes
New Member
- Joined
- Dec 13, 2010
- Messages
- 19
Hi I have the below VBA code that currently picks up and remembers the sequence of numbers. I am trying to change this so that it only picks up the same number once. The numbers will always be in acending order.
This is a loop and it enters the sequence in a certain cell so that it then initiates the next part of the macro. before moving to the next number in the sequence.
EG.
list of full numbers: 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 8, 9.
This currently pulls back: 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 8, 9.
I require it to be: 1, 2, 3, 4, 5, 6, 7, 8, 9.
Any help would be appreciated.
Sub LOOP_()
Dim Companies() As String
Dim count As Integer
Dim i As Integer
Dim finished As Boolean
Dim topoflist As String
count = 0
Sheets("Input of paragon").Activate
Range("A2").Select
topoflist = ActiveCell.Value
'Sheets("Data Input").Select
'Range(topoflist).Select
Do
count = count + 1
ReDim Preserve Companies(count)
Companies(count) = ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Value = "" Then finished = True
Loop Until finished
Range("a1").Select
For i = 1 To UBound(Companies)
Sheets("test").Activate
Range("a1").Value = Companies(i)
Calculate
Call rename_sheet
Next
End Sub
Sub rename_sheet()
Sheets.Add.Name = "Sheet1001"
Sheets("input of paragon").Select
Sheets("Sheet1001").Name = Range("w11").Text
End Sub
This is a loop and it enters the sequence in a certain cell so that it then initiates the next part of the macro. before moving to the next number in the sequence.
EG.
list of full numbers: 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 8, 9.
This currently pulls back: 1, 1, 1, 2, 2, 3, 3, 3, 3, 3, 4, 4, 4, 5, 6, 7, 8, 9.
I require it to be: 1, 2, 3, 4, 5, 6, 7, 8, 9.
Any help would be appreciated.
Sub LOOP_()
Dim Companies() As String
Dim count As Integer
Dim i As Integer
Dim finished As Boolean
Dim topoflist As String
count = 0
Sheets("Input of paragon").Activate
Range("A2").Select
topoflist = ActiveCell.Value
'Sheets("Data Input").Select
'Range(topoflist).Select
Do
count = count + 1
ReDim Preserve Companies(count)
Companies(count) = ActiveCell.Value
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Value = "" Then finished = True
Loop Until finished
Range("a1").Select
For i = 1 To UBound(Companies)
Sheets("test").Activate
Range("a1").Value = Companies(i)
Calculate
Call rename_sheet
Next
End Sub
Sub rename_sheet()
Sheets.Add.Name = "Sheet1001"
Sheets("input of paragon").Select
Sheets("Sheet1001").Name = Range("w11").Text
End Sub