?
Solved

FO Formatting

Posted on 2015-01-31
16
Medium Priority
?
111 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:Naresh Patel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
16 Comments
 
LVL 31

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:Naresh Patel
ID: 40582088
Please Suggest - What is suitable way to achieve instead of above mentioned steps.

Thanks
0
 
LVL 8

Author Comment

by:Naresh Patel
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
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 31

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:Naresh Patel
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 31

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:Naresh Patel
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 31

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:Naresh Patel
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 31

Expert Comment

by:gowflow
ID: 40582486
ok fine. Let me get back to you.
gowflow
0
 
LVL 31

Accepted Solution

by:
gowflow earned 2000 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:Naresh Patel
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 31

Assisted Solution

by:gowflow
gowflow earned 2000 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:Naresh Patel
ID: 40583175
Perfect - May I Ask Follow Up.
0
 
LVL 31

Expert Comment

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

Author Comment

by:Naresh Patel
ID: 40583869
here it is.


Thanks
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Cancel future meetings from user mailboxes in Office 365 using Remove-CalendarEvents
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

741 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