|
|
#1 |
|
Lively Member
Join Date: Mar 03
Location: singapore
Posts: 86
![]() |
Check txt file 4 mealbreak n display in XL??
Im reading in a text file in Excel...There are data like this:
TT101,B01,MB1,0,1,rmk TT101,C02,C12,5,6, etc etc etc in it.. The first param is an ID then,from blk, to blk, start time, end time, remarks..remarks is blank sometimes.. When reading the file, if it encounters "MB1" then my program should check which blk and in which period it falls.. (The first param is an ID then,from blk, to blk, start period, end period, remarks). Getting this info, it should go to the sheet(attchaced is the file) and check the periods against the blk (take a good look at it pls). If lets say it gets the data as above (TT101,B01,MB1,0,1,rmk) then it should highlight and print the word MB1 or MB2(I've shown it in the file at cell O3, pls download n see) Thanks alot for help guys..Pls help..
|
|
|
|
|
#2 |
|
I don't do your homework!
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
![]() ![]() |
Hi ITBoy,
you are obviously working on a bigger application, asking this forum to help you out on some problems. Reading your threads makes me wonder a bit. Do you only copy and paste the code given in here into your application? Or why do you encounter problems because, some information is hendled in different UserForms. It just sounds fishy to me! I do hope you have a plan for your complete application, if not you'll be lost within the next couple of weeks in all that muddle of code-pieces you patch together!!!! But now to your recent question: WHAT do you want?? I guess you know by now how to read from your textfile. You should also know how to fill specific cells in your EXCEL-file. More specific , you should be able to mark specific cells in your EXCEL-file that match a given Period and "BLk" (Using the code I gave you). So the only thing you should need is the logic that gives you the Period and the Blk for each Line of the textfile; isn't it! To help you in this, please ******** the "from Blk" and "to Blk" . In your example the "from Blk" is B01, that'S understood, but what is the "to Blk" (the Value is MB1, a value that hasn't been in the Blk-Values so far). Is it correct that the Endtime makes the Period? The second example would be Period 6 for blk C02 but in here the second Blk is C12, which is a "normal" one ?????????
__________________
You're welcome to rate this post! If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry! |
|
|
|
|
#3 |
|
Lively Member
Join Date: Mar 03
Location: singapore
Posts: 86
![]() |
Yes Opus..I do agree that i do copy paste codes from here to a certain extent but most of the time i do it by myself or make modifications to codes given here. As you've asked "C12" goes with period 6 and C02 with 5 (thinnk u forgot is it).. is the correct data(only blks) but now i heard that some data from the engine may come with MB1 or MB2 in either of the 2 columns so in such situation have to highlight a cell in Sheet1 as shown in attached file..Thanks Opus..
Last edited by ITboy; Apr 10th, 2003 at 12:11 PM. |
|
|
|
|
#4 |
|
I don't do your homework!
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
![]() ![]() |
OK, so you only need to know if one of the "from Blk" and "to Blk" Values is MB1.
Assuming you read each line of the textfile into a StringVar. do that for each line: VB Code:
__________________
You're welcome to rate this post! If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry! |
|
|
|
|
#5 |
|
Lively Member
Join Date: Mar 03
Location: singapore
Posts: 86
![]() |
I dont understand value3 and value 4..Can u pls show me a sample code..?thanks.
|
|
|
|
|
#6 |
|
I don't do your homework!
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
![]() ![]() |
Your textfile looks like:
TT101,B01,MB1,0,1,rmk You read that into StringVar after the Command VB Code:
Values(0)="TT101" Values(1)="B01" Values(2)="MB1" Values(3)="0" Values(4)="1" Values(5)="rmk" So the Periods are in Values(3) and Values(4), since they are Strins you need the Use Val(Values(3)) to make them to Numbers!
__________________
You're welcome to rate this post! If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry! |
|
|
|
|
#7 |
|
Lively Member
Join Date: Mar 03
Location: singapore
Posts: 86
![]() |
It highlights the function "Split" saying Sub or Function Not defined..
|
|
|
|
|
#8 |
|
I don't do your homework!
Join Date: Jun 00
Location: Good Old Europe
Posts: 2,783
![]() ![]() |
I pasted the code from EXCEL-VBA after testing it!!
Split is a build-in from VBA!!!!!! You do have StringVar and Values() declared, don't you!
__________________
You're welcome to rate this post! If your problem is solved, please use the Mark thread as resolved button Wait, I'm too old to hurry! |
|
|
![]() |
|
||||||
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|