Another table to txt Q

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a table as follo
1 2 3 4
A +
B + +
C + + +

How can I get saved on a txt file the following interpretation of the tabl

A
B
B
C 1
C
C
C

Thanks
 
One way:

name your table, say "table", including both the column and row headers.


Public Sub TableToTextFile()
Dim vArr As Variant
Dim i As Long
Dim j As Long

Open "Test.txt" For Output As #1
vArr = Range("table").Value
For i = 2 To UBound(vArr, 1)
For j = 2 To UBound(vArr, 2)
If vArr(i, j) = "+" Then _
Print #1, vArr(i, 1) & vArr(1, j)
Next j
Next i
Close #1
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top