Add missing numbers in a sequence
Hi Jack
Try this:
Sub aaa()
'Dim myArr
Dim rng As Range
Set rng = Range("A1", Range("B1").End(xlDown))
myArr = Array(rng.Value)
rCount = Range("A1").End(xlDown).Row
Range("A1") = 1
Range("A2") = 2
Range("A1:A2").Select
Selection.AutoFill Destination:=Range("A1:A150"), Type:=xlFillDefault
Range("B1:B150") = 0
For r = 1 To rCount
Cells(myArr(0)(r, 1), 2) = myArr(arr)(r, 2)
Next
Columns("A").NumberFormat = "###000"
End Sub
Regards,
Per
"jack" skrev i meddelelsen
...
I have data (example as shown below) that exports from a database in excel
file format on a daily basis.
What I need to do is insert the missing sequential numbers (starting with
001 and ending with 150) in each cell in column A and add a value of zero
for the missing sequential numbers in column B.
I'm at a loss as how to do this!
How I can accomplish with VBA (or another method) ?
Thanks..
Jack
A B
004 67
005 11
006 30
007 14
008 3
009 2
010 1
011 9
014 5
015 12
016 1
018 73
021 28
022 4
024 2
025 1
026 3
027 23
033 1
035 2
036 1
038 12
040 1
044 5
047 1
051 31
052 5
055 1
056 3
057 2
060 26
066 1
067 1
072 14
073 6
080 6
081 2
082 41
088 8
089 1
091 28
092 1
102 1
103 1
104 1
118 2
|