Results 1 to 10 of 86

Thread: Copy Paste based on comparisons calculations in 2 XL files, 1 might be .csv file .Opened in XL=Fail/Chaos

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #37
    Fuhrer, Vierte Reich DocAElstein's Avatar
    Join Date
    Aug 2014
    Posts
    10,457
    Rep Power
    10
    The problem is that text files cannot be analysed by a worksheet type way for like last row
    Lr= ….. .End(Xlup).row ….… and so on. That does not work in a text file. We do not have rows in a text file

    In a text file, we talk about instead lines and records

    Excel file row is only approximately = Text file line or Text file record

    In text file for last record, or last line, we use
    EOF ( https://docs.microsoft.com/en-us/off...p/eof-function )

    Or

    we do it another way. Your file in post#1 was like
    NSE, ,
    NSE, ,
    NSE, ,
    , ,
    , ,
    , , Explanation etc .


    So I did do check for “NSE,” for last data that you wanted

    So for no extra lines like below, like in sample2BEFORE.csv , it does not work too well
    NSE, ,
    NSE, ,
    NSE, ,


    ( See here for more info, just for info, not important :
    Original text files : https://excelfox.com/forum/showthrea...ge32#post13475
    https://excelfox.com/forum/showthrea...ge32#post13476

    Text files post#29 : https://excelfox.com/forum/showthrea...ll=1#post13618
    )




    So solution to this problem
    Change .._
    Code:
        Do While Left(TextFileLineIn, 4) = "NSE," ' For text file lines like   NSE,101010,6,<,12783,A,,,,,GTT that may have extra unwanted lines like in one Avinash uses stupidly for explanations
         Let RwCnt = RwCnt + 1
         Line Input #FileNum, TextFileLineIn '  next line in text file
        Loop
    -..To this
    Code:
        Do While Not EOF(FileNum) = True And Left(TextFileLineIn, 4) = "NSE," '  Left(TextFileLineIn, 4) = "NSE," ' For text file lines like   NSE,101010,6,<,12783,A,,,,,GTT that may have extra unwanted lines like in one Avinash uses stupidly for explanations
         Let RwCnt = RwCnt + 1 ' for first and subsequent lines given by below. ... but
         Line Input #FileNum, TextFileLineIn '  next line in text file
        Loop
        If EOF(FileNum) = True Then Let RwCnt = RwCnt + 1    '                  ... but if the last line I want is EOF, I will not catch it in the loop so must add a 1 here 
    Full macro here:
    https://excelfox.com/forum/showthrea...ll=1#post13619






    Share ‘sample2BEFORE.csv’ : https://app.box.com/s/d8lu7iatfv6h8spp9eru8asm3h4v4e4p
    Share ‘Sample2After.csv’ : https://app.box.com/s/0j4118cwzzofe76ytb5rqkvz3qj0vseu
    vba.xlsm : https://app.box.com/s/juekenyll42z84j6ms7qonzsngnugoyo
    Sample1.xls : https://app.box.com/s/xh58fgjl74w06hvsd53jriqkohdm6a3q
    macro.xlsm : https://app.box.com/s/z358r7tbc9hzthi539dlj49jsf4gyg8p
    1.xls : https://app.box.com/s/38aoip5xi7018y9syt0xe4g04u95l6xk

    Last edited by DocAElstein; 06-09-2020 at 02:03 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: 26
    Last Post: 09-26-2020, 05:56 PM
  2. Copy paste data based on criteria
    By analyst in forum Excel Help
    Replies: 7
    Last Post: 01-13-2014, 12:46 PM
  3. Replies: 8
    Last Post: 10-31-2013, 12:38 AM
  4. Replies: 2
    Last Post: 09-18-2013, 12: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
  •