Link to home
Start Free TrialLog in
Avatar of Naresh Patel
Naresh PatelFlag for India

asked on

FO Formatting

Hi Experts,

I have one WB which perform - Download file form server as Zip - VBA unzip that file and format.
Referring 4th button in WB i.e. Future & Option.
Current Code Perform this steps
Delete all files from this location "D:\AmiBroker Data\NSE\F&O"
1 Download Zip From Start date to End Date
2 Unzip that files.
3 Find text "NIFTY" in column B which is mostly 3 match found in column B
4 Register that three dates in column C which match to "NIFTY" and gave name instead of date as "I" "II" & "III"
5 Apply above to all in column C as per date i.e. "I" "II" "III".
6 Delete other rows which is not same as earlier match i.e. step 3 and step 4.
7 Apply formula in cell P2
=IF(OR(A2="FUTSTK",A2="FUTIDX"),B2&" "&C2&","&TEXT(O2,"DD-MMM-YY")&","&F2&","&G2&","&H2&","&I2&","&K2&","&M2,IF(OR(A2="OPTIDX",A2="OPTSTK"),B2&" "&C2&" "&D2&" "&E2&","&TEXT(O2,"DD-MMM-YY")&","&F2&","&G2&","&H2&","&I2&","&K2&","&M2,""))

Open in new window

& formula drop down till end.
8 copy whole column P and past to new .txt file and delete original .csv file
9 next file till end.

Modification which I looking to
Need 2 .text file from .csv file.
After step 7
1 Sort A to Z Column E
2 Copy column P data only where in column E cell value = "xx" with header
3 past these data to new .txt file and name as "F" & actual .csv file name.
4 save to this location "D:\AmiBroker Data\NSE\F&O\Future"
5 Copy column P data only where in column E cell value not ="xx" with header
6 Past to new .txt file and name as "O" & actual .csv file name.
7 Save to this location"D:\AmiBroker Data\NSE\F&O\Option"
8 Next .csv file.

Note
After clicking button before downloading it delete all file from this location "D:\AmiBroker Data\NSE\F&O"
but if we apply above modification then there will be files in two folders i.e. "Future" & "Option". so have to delete all files from this folders not in "D:\AmiBroker Data\NSE\F&O" this location.

In existing file code line need to change for formula as current produce this row data ABIRLANUVO,I,1000,CE,27-Jan-15,0,0,0,665.35,0,0 but actual in file is like this ABIRLANUVO I 950 CE,06-Jan-15,0,0,0,714.2,0,0
 i.e. first coma start before date

Thanks
Incoporated-Download-File-V13.xlsm
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

This is a ZIG ZAG from the previous logic !!! I call this spaghetti programming !!!!
you had 1 directory 1 button

Now you want 1 button 1 directory with 2 sub directories !!!
I think this is not healthy !

When you start the procedure it delete all files in the said directory now there will be NO files in the main directory but there will be Files in the sub directories ...

Too many 'spagetti' situations.

I think if you want a solution you need to re-think it !!!
NOTE that is my opinion for sure you will find people who will do the spaghetti that you want ...

gowlfow
Avatar of Naresh Patel

ASKER

Please Suggest - What is suitable way to achieve instead of above mentioned steps.

Thanks
Or if above process create more blunder then I am happy with existing just need to implement Quote section I.e. first coma before date.

Thanks
No problem we cater for everything here is my suggestion:

The way I see it is the following:

You had on the 4th button 1 directory
"D:\AmiBroker Data\NSE\F&O"

Now you have practically the following:
"D:\AmiBroker Data\NSE\F&O"    ---> Does not exist any more so we have a free 4th button
We can do the following:
for the 4th button replace the address to be:
"D:\AmiBroker Data\NSE\F&O\Future"
and amend the code so it works for Future as you described above.

Then Create a new button 7 for
"D:\AmiBroker Data\NSE\F&O\Options"
and amend its code so it works for Options as you described above.

This is in very general terms.

OR

We can keep 4th button as is
and  Create 7 and 8 for Future, Option respectively.

You need to advise as you know better if what you had in 4th is still to be used or totally obsolete .... ???

Pls advise.
gowflow
We can do the following:
 for the 4th button replace the address to be:
 "D:\AmiBroker Data\NSE\F&O\Future"
 and amend the code so it works for Future as you described above.

Then Create a new button 7 for
 "D:\AmiBroker Data\NSE\F&O\Options"
 and amend its code so it works for Options as you described above.

 This is in very general terms.

Sound Logical but for future and option both using same file ....so you mean if we create separate buttons then it will download same file twice when clicking this two separate buttons?

Thanks
Yes we don't care if it uses the same file it will download it twice at least it is a neater solution and much better.

If you don't need 4 at all then we can replace 4 and create 7
But if you will nowhow need 4 then I suggest we keep it and create 7 and 8 for Future and options.

gowflow
Ok I think we have to keep it 4th button and create new for future and option. But one request can't we numbered down 4th button to last in place?

Thanks
Yes but you need to decide what this question will be about as need to renumber all other butons as well and change the whole layout to fit for 2 more buttons which alone is a lot of work !!!

I hope (for you) that you don't have more additions like this you need to think about all this in the desgn phase.

I would suggest this question to prepare for options/future and move 4 to last and prepare for 2 new to be in 4 5 and move 5 6 to 6 7 and have 4 in 8.

then when this is done you can ask a related for Future and once done ask a related for Options and I guess you will need to incorporate all this into 1 click which will be the last.

Also need maybe to decide about 4 becoming 8 to decide if it will be included in the one click or simply manual all the time.

gowflow
I would suggest this question to prepare for options/future and move 4 to last and prepare for 2 new to be in 4 5 and move 5 6 to 6 7 and have 4 in 8.

Agreed this question only for Buttons
then Future
         Option
         Master Button (Excluding 8 Button)

Thanks
ok fine. Let me get back to you.
gowflow
ASKER CERTIFIED SOLUTION
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i had checked all working perfect. Future and Option remain as it is as we have to implement in next questions. but in last button "Future & option" it produce .txt files - here little modification required - 2nd row line appear like this ABIRLANUVO,I,1000,CE,29-Jan-15,0,0,0,665.35,0,0 but actual required this ABIRLANUVO I 1000 CE,29-Jan-15,0,0,0,665.35,0,0

Thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Perfect - May I Ask Follow Up.
Yes please go ahead.
gowlfow