Hi,
my macro code:
Sub MAKRO()
Close #1
plik_txt = Application.GetOpenFilename("Pliki txt(*.csv;*.txt),*.csv;*.txt")
Open plik_txt For Input As #1
'Open ".\dane.txt" For Input As #1
wrs = 1
Do Until EOF(1)
kol = 1
Line Input #1, textline
tbl = Split(textline, ",")
For i = 0 To UBound(tbl)
Cells(wrs, kol) = tbl(i)
kol = kol + 1
Next
wrs = wrs + 1
Loop
For j = 1 To wrs - 1
Dim iname As String
Sheets.Add After:=Sheets(Sheets.Count)
'iname = Chr(34) & "Sheet" & i & Chr(34)
iname = "Sheet" & j
Sheets(iname).Select
'Sheets("iname").Name = "aaa"
Next j
Close #1
Problem:
Iname can't be understood by Sheets(iname).Select. As you can see I tried to add special signs to simply read correct name, but VBA don't get it.
This code part is opening external file *.txt, which contains in column names, ie:
WIERSZ1
WIERSZ2
WIERSZ3
WIERSZ4
....
I would like to add sheets which names are as in external file. My idea was to open this file, read rows, create sheets and rename them. After that I would read to those worksheets data from other files I have and which names are: WIERSZ1.csv, WIERSZ2.csv, WIERSZ3.csv... but just wondering if this code is not too sophisticated and if there's no easier way to achieve the same result in few lines.
Thanks for help.
Bookmarks