Solved

FO Formatting

Posted on 2015-01-31
16
96 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
ID: 40581764
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
ID: 40582088
Please Suggest - What is suitable way to achieve instead of above mentioned steps.

Thanks
0
 
LVL 8

Author Comment

by:itjockey
ID: 40582164
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 29

Expert Comment

by:gowflow
ID: 40582207
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
ID: 40582223
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
ID: 40582233
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
ID: 40582236
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
ID: 40582428
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
 
LVL 8

Author Comment

by:itjockey
ID: 40582441
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
ID: 40582486
ok fine. Let me get back to you.
gowflow
0
 
LVL 29

Accepted Solution

by:
gowflow earned 500 total points
ID: 40582573
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
ID: 40582593
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
ID: 40582829
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
ID: 40583175
Perfect - May I Ask Follow Up.
0
 
LVL 29

Expert Comment

by:gowflow
ID: 40583649
Yes please go ahead.
gowlfow
0
 
LVL 8

Author Comment

by:itjockey
ID: 40583869
here it is.


Thanks
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager is not included in Office 2013. This comes as a shock to users upgrading from earlier versions of Office, such as 2007 and 2010, where Picture Manager was included as a standard application. This article explains how…
Outlook Free & Paid Tools
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar 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.

806 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