Next solution attempt for this:
https://excelfox.com/forum/showthrea...ll=1#post13219
Do not put a code line in the macro to open 2.csv!
Code:Sub Step14_DogShit() ' https://excelfox.com/forum/showthread.php/2467-COPY-AND-PASTE?p=13219&viewfull=1#post13219 Rem 1 Worksheets info Dim w1 As Workbook, w2 As Workbook, w3 As Workbook Set w1 = Workbooks("1.xls") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\1.xlsx") ' Do Not open 2.csv ' Set w2 = Workbooks("2.csv") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\document\2.csv") Set w3 = Workbooks("3.xlsx") ' Workbooks.Open("C:\Users\WolfieeeStyle\Desktop\files\3.xlsx") Dim Ws1 As Worksheet, Ws2 As Worksheet, Ws3 As Worksheet Set Ws1 = w1.Worksheets.Item(1) ' Set Ws2 = w2.Worksheets.Item(1) Set Ws3 = w3.Worksheets.Item(1) Dim Lc3 As Long, Lenf1 As Long, Lr1 As Long Let Lr1 = Ws1.Range("A" & Ws1.Rows.Count & "").End(xlUp).Row ' http://www.excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=11466&viewfull=1#post11466 Making Lr dynamic ( using rng.End(XlUp) for a single column. ) ' Let Lc3 = Ws3.Cells.Item(1, Ws3.Columns.Count).End(xlToLeft).Column ' Dim Lc3Ltr As String ' Let Lc3Ltr = CL(Lc3) Rem 2 ' In 1.xls count the total number of rows that has data and copy the 3.xlsx sheet3 first row(first complete row copy) and paste that much time of 3.xlsx first row of sheet3 to 2.csv Let Lenf1 = Lr1 - 1 ' 1.xls first row has headers so dont count that ' 2a) get range to be put into dog shit files Dim arrIn() As Variant: Let arrIn() = Ws3.Range("A1:K1").Value ' 2b) make a string fow a row, including a dog shit Tab seperator Dim cnt For cnt = 1 To UBound(arrIn(), 2) ' Column count in worksheet 3 row 1 Dim strLine As String Let strLine = strLine & arrIn(1, cnt) & vbTab Next cnt Let strLine = Left(strLine, (Len(strLine) - 1)) ' Take off last Tab ' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strLine) ' "NSE" & vbTab & vbTab & "6" & vbTab & vbTab & vbTab & "A" & vbTab & vbTab & vbTab & vbTab & vbTab & "GTT" ' 2c) repeat string to include (and include line breaks) to make complete string for do shit text files For cnt = 1 To Lenf1 ' row count of our dog shit text files Dim strTotalFile As String Let strTotalFile = strTotalFile & strLine & vbCr & vbLf Next cnt ' Call WtchaGot_Unic_NotMuchIfYaChoppedItOff(strTotalFile) ' https://excelfox.com/forum/showthread.php/2345-Appendix-Thread-(-Codes-for-other-Threads-HTML-Tables-etc-)?p=13218&viewfull=1#post13218 Rem 4 make dogshit files ' 4a) Dog Shit text Dim Highway1 As Long: Let Highway1 = FreeFile(0) 'range 1 – 255, inclusive - next free Open ThisWorkbook.Path & "\" & "DogShit.txt" For Append As #Highway1 ' Will be made if not there Print #Highway1, strTotalFile Close #Highway1 ' 4b) 2.csv Dim Highway2 As Long: Let Highway2 = FreeFile(0) 'range 1 – 255, inclusive - next free Open ThisWorkbook.Path & "\" & "2.csv" For Append As #Highway2 ' Will be made if not there Print #Highway2, strTotalFile Close #Highway2 Rem .... ' w1.Close ' w2.Save '' Let Application.DisplayAlerts = False '' w2.Close '' Let Application.DisplayAlerts = True ' w3.Close ' End Sub




Reply With Quote
Bookmarks