Posts by dilshod_k

    Hello everyone,


    I have routine that loops through the cells in the column "K" with stock symbols and opens corresponding to them files in the folder. I'd like to modify code so that during runtime it would show progress in the status bar. Any help would be appreciated. Thank you in advance.


    Thank you for advice. I'm just beginner in coding, the info in the link is too complicated for me. I found easier way to change color of the status bar: File/Options/General/Office Theme - White - Status bar remains green, but font color changes to white and that makes it better visible.

    Thanks for you help anyway.

    Dilshod

    Add at the beginning at the end of your macro the lines marked: '<= added and choose what to do with the line marked:

    Code
    '<= do not use or change to True

    Hello Rollis13.

    Thanks a lot for your code. It is working perfectly well. The only problem is that when the macros is running status bar becomes dark green, so the black font with dark green background I could hardly able to see. Of course it is not your fault. I was wandering is there any chance to modify code so that it would display progress bar with percentage, so that I could adjust size and color of the font and background to my vision? Thank you in advance.

    Dilshod

    Hello everyone,


    The code below loops through multiple files in folder. I would like to write code which displays progress bar with percentage of files processed or progress of this macro in the Status Bar, whichever is easier for you. Thank you in advance for your help and suggestions.


    Dilshod


    Possibly...

    The On Error Resume Next line may be hiding a problem in the called macro...?

    Hi dangelor! I was so happy that there was no problem with workbook self closing, that I have not noticed that the new code stopped updating historical price data in CSV files. Instead of pasting (or inserting) historical price data it just makes Cell B2 blank. Any chance to find out where is the error in the code? Thanks again.

    Thanks for suggestion Roy. I heard about FileExists function, but I have no experience of using it whatsoever. Apart from that the sub I'm trying to create will be updating thousands of files, with possibly dozens of them missing, so I'm trying to automate as many functions as it is possible. Interruption for message box will delay everything. Is it possible with this function not only to confirm file existence (or absence) but to create CSV file if it does not exist? Thanks in advance.


    Dilshod


    Dilshod

    Thank you so much! It is working now without any problems. I was wandering, is there any way to record stock symbols (lets say somewhere in the column M) that cause errors because their corresponding files do not exist in the folder? When it comes to hundreds of stock symbols sometimes it is difficult manually to figure out new stock, file for which is not available. Thank you in advance and highly appreciate your help.


    Possibly...

    Code
        On Error Resume Next                          'MIGHT BE HIDING AN ERROR CAUSING YOUR PROBLEM

    I'm not trying to close workbook. It closes by itself if it can't find CSV file corresponding to stock symbol. For example, if you place stock symbol in the cell "S5", like XYZ. If the file XYZ.csv is available in the folder C:\VBA\, then macros works without problems, but if it is not there in the folder, instead of giving error message workbook closes by itself, i.e. macros closes workbook in which it is located. I hope someone will be able to figure out how to sort out this problem. Thank you.

    Hello everyone,

    I would be grateful for any help with workbook closing itself in the middle of macros run-time. The macros downloads list of stocks historical price data and inserts them in the corresponding to each stock CSV file in the folder C:\VBA\. Names of CSV files are equal to their corresponding stock symbols. If stock symbol is XYZ then its file will be XYZ.csv. Whenever corresponding to stock symbol CSV file can’t be found in the folder with CSV files, workbook closes itself in the middle of run-time. I can't figure out how to solve this problem. Thanks in advance for any help.


    Hello Alan,


    Sorry, I did not expect that solution found personally by the author of the post might be interesting to others.

    Yesterday was day off, apparently due to this reason my post remained unattended on both websites.

    I did homework and succeeded to find solution myself. The code is as it follows below.

    Kind regards,


    Dilshod


    Hello everyone.


    I would like to simplify task as my explanation of the whole task might be confusing.


    I have a folder C:\VBA with number of CSV files. Names of the files might be 1 to 6 letters.


    For example: A.csv, MN.csv, XYZ.csv, OPRS.csv, TVIXF.csv etc.


    I need piece of code which finds file, the name of which is matching current value of the cell B4, Sheet2, This workbook in text format.


    For example, If cell B4 value is XYZ the code has to find and open file XYZ.csv in C:\VBA


    Thanks in advance. I would be grateful for any help.

    So ou just want to import the existing data from the csv files? Sounds like it will be a massive amount of data.

    Thanks for your message.

    Sorry for my English, it is not my native language. Apparently I could not explain properly. It is the other way round, I want to pull data to CSV files. Let's say the folder with CSV files has historical price data starting from 01/01/2017 up to 24/11/2020. Today is 06/12/2020. I need to download stock prices for the last few days starting from 25/12/2020 up to date, copy and paste these data in each corresponding file in the folder with CSV files. For example if I have stock symbols ABC, LMN, XYZ in the column K, I need to download price data for all these symbols and then paste this data into each corresponding file namely ABC.csv, LMN.csv, XYZ.csv in the folder C:\VBA. I've composed macro to loop through all cells in the column K and download prices but I got stuck as I do not know how to find corresponding to stock symbol CSV file in the folder C:\VBA and open it. If you have any questions please let me know. Thanks in advance for your help.

    What's not working for you? It looks like the code is commercial from an addin.

    Thanks for your message. I've downloaded this file couple of years ago while it was free. It's an old version. Even after it became commercial authors of the code mentioned on their website that they have no objections against VBA modifications. I'm trying to modify it to my needs. The aim is to create back testing simulator. I've bunch of CSV files with 3 years historical price data of the stocks. The historical price data for the last several days are missing. In order to avoid downloading all data from scratch for the last three years again I want to download data for the last few days and copy and paste data in the corresponding files in order to update them. Their workbook is not expensive and I would by it if it would help me. I believe this function is not available even in commercial version of the file. Thanks in advance for your help.