Solved

FO Formatting

Posted on 2015-01-31
16
85 Views
Last Modified: 2015-02-02
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
0
Comment
Question by:itjockey
  • 8
  • 8
16 Comments
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
Please Suggest - What is suitable way to achieve instead of above mentioned steps.

Thanks
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
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
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
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
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
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
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
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
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 8

Author Comment

by:itjockey
Comment Utility
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
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
ok fine. Let me get back to you.
gowflow
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
Comment Utility
ok pls check this version. Make sure all the known buttons works correctly and also try the Do it all. It will skip the last one Future and Options.

Let me know.
gowflow
Incoporated-Download-File-V14.xlsm
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
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
0
 
LVL 29

Assisted Solution

by:gowflow
gowflow earned 500 total points
Comment Utility
ok in module aStartFO in Sub CreateTXT pls replace this formula with this one:

WS.Range("P2:P" & MaxRow).Formula = "=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


gowflow
0
 
LVL 8

Author Closing Comment

by:itjockey
Comment Utility
Perfect - May I Ask Follow Up.
0
 
LVL 29

Expert Comment

by:gowflow
Comment Utility
Yes please go ahead.
gowlfow
0
 
LVL 8

Author Comment

by:itjockey
Comment Utility
here it is.


Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now