Hi All,
I have the below script which produces output in different cells , I want to be able to save separate CSV files of the output generated.Kindly help. (File Attached)
Sub test()
Dim a, e, i As Long, myOS, x, y, n As Long, dic As Object
Set dic = CreateObject("Scripting.Dictionary")
dic.CompareMode = 1
myOS = Array(Array("WIN", 50), Array("UNIX", 100), Array("AIX", 100), _
Array("Linux", 100), Array("Solaris", 100), Array("etc", 100))
For Each e In myOS
dic(e(0)) = Array(Empty, 0, e(1))
Next
a = Cells(1).CurrentRegion.Value
For i = 2 To UBound(a, 1)
If dic.exists(a(i, 2)) Then
If IsEmpty(dic(a(i, 2))(0)) Then
ReDim x(1 To 1), y(1 To dic(a(i, 2))(2))
Else
x = dic(a(i, 2))(0): y = x(UBound(x))
End If
n = dic(a(i, 2))(1) + 1
If n > dic(a(i, 2))(2) Then
ReDim Preserve x(1 To UBound(x) + 1)
ReDim y(1 To dic(a(i, 2))(2)): n = 1
End If
y(n) = a(i, 1): x(UBound(x)) = y: dic(a(i, 2)) = Array(x, n, dic(a(i, 2))(2))
End If
Next
Columns("e").ClearContents: n = 3
For Each e In dic
x = dic(e)(0)
If Not IsEmpty(x) Then
For i = 1 To UBound(x)
n = n + 1: Cells(n, "e").Value = e & " " & i
n = n + 1: Cells(n, "e").Value = Join(x(i), ", ")
Next
n = n + 1
End If
Next
End Sub
Bookmarks