Plz download it from below link
https://drive.google.com/file/d/1Tyf...ew?usp=sharing
https://drive.google.com/file/d/1X2M...ew?usp=sharing
Plz download it from below link
https://drive.google.com/file/d/1Tyf...ew?usp=sharing
https://drive.google.com/file/d/1X2M...ew?usp=sharing
OK, good, I see the problem.
I will post the solution later .
A Folk, A Forum, A Fuhrer ….
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 .._
-..To thisCode: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
Full macro here: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
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.
A Folk, A Forum, A Fuhrer ….
Thnx Alot Doc Sir for Helping me in solving this problem
& What u suggest, I completely agree with not to play with CSV file & I have decided I will change .CSV to XLSX & then from XLSX to notepad
& I will upload notepad data to my system not the CSV file
It is the best way,I think
What u suggest?
I tell you now already 101 times… there are no such things as notepad files , notepad data … etc… you mean text files
Biggest Problem is not text files
Excel files sometimes have problem. Excel files sometimes have no problem
Text files sometimes have problem. Text files sometimes have no problem
It makes no difference to use only Excel , or only text, or both. Problems remain the same
Using Excel to manipulate text is mostly no problem if you do it properly, like https://www.homeandlearn.org/open_a_...le_in_vba.html
To open in Excel or to save a file from Excel to text can give problems often.
It makes no difference for Avinash to use text files or Excel files
You do not understand VBA or Excel or text files. This is a problem. It makes no difference if you use text or Excel. This is a problem, but not the biggest problem..
Biggest problems are
_ Avinash does not understand English
_ Avinash replies too quickly, does not read or understand, and makes mistakes
So we all waste lots of time
Example
We wasted a whole day because
_ Avinash did not understand this:
____ Upload the file that gives you the error
_ Avinash made mistakes and uploaded wrong files
That was big problem.
The problem with the macro was very small.
I am not really sure ahat you mean, but
Biggest problems are from converting/ changing from text ( .csv ) to Excel or Excel to text etc..
Excel files should stay Excel files
Text files ( .csv) should stay text files.
My macros, ( and jindons macros ) have Excel file stay as Excel File, Text file stay as text file.
No changing or converting Excel to text, text to excel
This is best.
( I do not have anymore time for you today. I look again tomorrow
)
A Folk, A Forum, A Fuhrer ….
Yes plz, but do not look this question
This is Solved
Problem Solved
Bookmarks