+ Reply to Thread
Results 1 to 17 of 17

add data from another worksheet every day

  1. #1
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    add data from another worksheet every day

    I have a worksheet named stock_price_check-test. i will open another worksheet named Bhavdata. form bhavdata the code should bring the close price and enter in col H after entering the date of the bhavdata in col G. then the macro should evaluate the price . if it is greater than the base price it should be in GREEN otherwise in RED. then it sould calculate the total price in col I. then it should compare the price and show profit or loss in col J. find out the percentage of profit and loss in col K.
    the process should continue for each forthcoming day adding data to the right.thanks. pls see the attachment.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    I need some clarification.
    What cells are added to determine the total price in column I?
    What cells are compared to determine the profit or loss in col J?
    What cells do you use to calculate the percentage of profit and loss in col K?
    Please explain using a few examples from your data stating the cells used and what the end result should be.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    thanks for the reply. kindly see the attached for clarification.
    Last edited by sumesh56; 03-20-2019 at 10:18 PM.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    It seems to me that once the close price from bhavdata is copied to col H then columns I, J and K will calculate automatically using the existing formulas. Therefore all the macro needs to do is insert the close price from bhavdata into column H and colour the cell red or green and alphabetize the data according to column B. Is this correct?

  5. #5
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    thanks for the reply.

    the formulas which has been shown has to be incorporated into the macro so that it will do the work automatically. the macro should also to show the date of the bhavdata in column G as requested.No need to alphabetically arrange.you may pls refer to the code which you have created for me earlier for guidance.pls see that the filename bhavdata , sec_bhavdata_200319 etc should be taken as one by the code. both the file will be opened .when new bhavdata is opened the latest data should be appended. the columns will extend towards right.for your guidance and test, i have uploaded bhavdata of three different days with a gap.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    Will the sheet name in each bhavdata workbook always be "sec_bhavdata_full"?

  7. #7
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    yes but i will edit it with the date to distinguish each one. like sec_bhavdata_full-200319,sec_bhavdata_full-210319 etc




    kindly refer to this thread post No 37 to see your own code.
    https://www.excelforum.com/excel-pro...ml#post4941014
    Last edited by sumesh56; 03-22-2019 at 12:19 PM.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    This macro assumes that only one bhavdata workbook will be open at any one time along with the Stock Price workbook.
    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    thanks for the macro. when i run the macro it gives an error . "Runtime Error 6" overflow.
    though it gives an error, it shows the data in col G-----K.
    I opened bhavdata of 19th .
    then i close it and opened bhavdata of 21st.then the previous data is erased and new data according to the 21st is added. it should not happen. after filling the data of 19th, when i run the macro for the second time of course after opening bhavdata of 21st, the new data should be appended from col L. it should continue.
    pls see the attached macro enabled file . now pls open bhavdata of 21st and see the result.bhavdata uploaded in post No.3
    Attached Files Attached Files

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    Try:
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    Thanks for the code. it seems that it works fine.can i ask you one more favour?
    The code requires the filename as STOCKPRICECHECK.
    Can you make it as stock*.*
    I wish that it works with any opened filename starting with stock
    like stockprice_april2019, stockprice_may2019 stockprice new,etc

    At present it need to be stockpricecheck only.
    Last edited by sumesh56; 04-06-2019 at 12:10 PM.

  12. #12
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    My pleasure.

  13. #13
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    STOCKPRICECHECK doesn't refer to the filename. It refers to the worksheet named "STOCKPRICECHECK". It doesn't matter what the filename is of the workbook containing the macro.

  14. #14
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    Quote Originally Posted by Mumps1 View Post
    STOCKPRICECHECK doesn't refer to the filename. It refers to the worksheet named "STOCKPRICECHECK". It doesn't matter what the filename is of the workbook containing the macro.
    thanks for the response. yes , i meant to say that the worksheet name. can you make it universal like stockprice.* like stockpricecheck_july 2019, stockpricecheck_aug2019, any sheet name for that matter which starts with stockprice

  15. #15
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    This macro assumes that the STOCKPRICECHECK sheet will always be the first sheet in the workbook.
    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    02-28-2012
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    542

    Re: add data from another worksheet every day

    Hi, thanks for the edited code. it works fine.
    Now i would seek some clarifications.
    when i get a new code i insert a module and paste it there. since i have a number of codes thus stored in my personal workbook, and when i open the macros button there is a long list of codes. to identifiy the required code i rename the code in properties window.
    for example for your latest code i have renamed as stockpricecheckMUMPS210419.
    when i open the code in the code window i See on the first line of the code=====copydata
    this is supposed to be the name of the code.
    is there any suitable way of renaming the code other than my method?please see the attached file
    Attached Files Attached Files

  17. #17
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: add data from another worksheet every day

    If you are storing the "CopyData" macro in a personal workbook, unfortunately I don't have any experience running a macro from a personal workbook. Why not keep the same macro name?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 06-24-2018, 06:02 PM
  2. Replies: 1
    Last Post: 03-12-2017, 01:02 PM
  3. [SOLVED] Copy data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-21-2012, 04:02 AM
  4. Copy data from a worksheet and paste to worksheet with a similar worksheet name
    By maacmaac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2012, 02:49 AM
  5. [SOLVED] Macro to Delete Data in one worksheet based of the data that is in another worksheet.
    By shortma in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-18-2012, 10:52 AM
  6. Data/shapes entered in worksheet, how do duplicate data to another worksheet?
    By barleycorn in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-22-2012, 04:57 PM
  7. Replies: 1
    Last Post: 07-26-2012, 06:14 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1