Export excel sheet data in to text file by iterating data with other sheet
Hi,
i am new to development, i have googled my requirement but i did not get what i am looking for.Below is my requirement..
i have to sheets(sheet1 and sheet2) in excel file.
Sheet1 has data of server name, starttime and endtime
sheet2 has user and his name.
i want to provide access to each user to the servers mentioned sheet1 in below format. and export that to text file
Re: Export excel sheet data in to text file by iterating data with other sheet
Here comes a solution.
I renamed the sheets with explicit names.
The output file name is Auth.txt in same directory as the .xlsm file
The date format must be adjusted, since it contains colons that might be understood as field separators.
To run the macro, hit Ctrl+r
HTH,
--
AP
PS: i read the OP more closely and noticed the correct date format. A new version comes soon.
Last edited by ArdusPetus; 04-04-2020 at 07:40 AM.
A VBA beginner starter according to the initial post so according to the original attachment as it is :
PHP Code:
Sub Demo1() Const D = ":", F = D & "mmddyyyyhhmm" Dim N%, V, L&, R&, S$ N = FreeFile V = Sheet1.UsedRange.Value2 For L = 2 To UBound(V): V(L, 2) = Format(V(L, 3), F) & Format(V(L, 4), F): Next Open ThisWorkbook.Path & Application.PathSeparator & "Export .txt" For Output As #N With Sheet2.UsedRange.Rows For R = 2 To .Count S = D & Join(Application.Index(.Item(R).Value2, 1, 0), D) For L = 2 To UBound(V) Print #N, V(L, 1); S; V(L, 2) Next L, R End With Close #N End Sub
► Do you like it ? ► ► So thanks to click on bottom left star icon « ★ Add Reputation » !
Bookmarks