Results 1 to 10 of 102

Thread: VBA Copy Rows From One Workbook To text csv File Based On Count In Different Workbook. Cross Posted Chaos

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    9,316
    Rep Power
    10
    My first answer here was almost perfect. https://excelfox.com/forum/showthrea...ll=1#post13185
    https://excelfox.com/forum/showthrea...ll=1#post13184


    This was your question:
    i have three files 1.xls & 2.csv & 3.xlsx
    1.xls first row has headers so dont count that
    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
    suppose 1.xls has data in 5 rows then copy 3.xlsx first row of sheet3 and paste it to 2.csv 5 times
    all files are located in a different path
    sheet name can be anything


    This question should have been you question:
    VBA To Copy Rows From One Workbook To text csv File, Based On Count In A Different Workbook
    I have three files: 2 Excel Files,1.xls & 3.xlsx , and a text file, 2.csv
    1.xls first row has headers so don't count that
    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 many rows of 3.xlsx first row of sheet3 to 2.csv
    suppose 1.xls has data in 5 rows then copy 3.xlsx first row of sheet3 and paste it to 2.csv 5 times
    all files are located in a different path
    sheet name can be anything

    The final result should be a comma separated values text file , 2.csv.
    For example, in Notepad, it looks like this:

    2csv is a comma seperated text file.JPG : https://imgur.com/FEjKVMs
    2csv is a comma seperated text file.jpg

    That is the final result that I want


    Here is the new answer from me : https://excelfox.com/forum/showthrea...ll=1#post13346

    Only a very small change was required:
    Code:
    ' 3b
     w2.SaveAs Filename:=ThisWorkbook.Path & "\2.csv", FileFormat:=xlCSV
     Let Application.DisplayAlerts = True
     w2.Close



    Avinash
    Read this, and try to understand at least a little of it.

    2.csv is a text file. It is not an Excel file.
    For example, in Notepad, it looks like this:
    2csv is a comma seperated text file.JPG : https://imgur.com/FEjKVMs
    2csv is a comma seperated text file.jpg

    2.csv is a text file. It is not an Excel file.
    You can open a .csv file in Excel, and Excel will do its best to display the data in columns


    Sometimes Excel will do this:

    _____ Workbook: 2.csv ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    D
    E
    F
    G
    H
    I
    J
    K
    L
    1
    NSE
    6
    A GTT
    2
    NSE
    6
    A GTT
    3
    NSE
    6
    A GTT
    4
    NSE
    6
    A GTT
    5
    NSE
    6
    A GTT
    6
    Worksheet: 2


    Sometimes Excel will do this:

    _____ Workbook: 2.csv ( Using Excel 2007 32 bit )
    Row\Col
    A
    B
    C
    1
    NSE,,6,,,A,,,,,GTT
    2
    NSE,,6,,,A,,,,,GTT
    3
    NSE,,6,,,A,,,,,GTT
    4
    NSE,,6,,,A,,,,,GTT
    5
    NSE,,6,,,A,,,,,GTT
    6
    Worksheet: 2


    Alan
    Last edited by DocAElstein; 05-17-2020 at 08:05 PM.
    ….If you are my competitor, I will try all I can to beat you. But if I do, I will not belittle you. I will Salute you, because without you, I am nothing.
    If you are my enemy, we will try to kick the fucking shit out of you…..
    Winston Churchill, 1939
    Save your Forum..._
    _...KILL A MODERATOR!!

Similar Threads

  1. Replies: 4
    Last Post: 04-10-2014, 10:58 PM
  2. Replies: 2
    Last Post: 09-18-2013, 12:30 AM
  3. TO convert Excel entire workbook in csv format
    By pritee in forum Excel Help
    Replies: 11
    Last Post: 08-16-2013, 11:28 AM
  4. Replies: 4
    Last Post: 06-20-2013, 04:25 PM
  5. Replies: 9
    Last Post: 09-09-2011, 02:30 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •