Incrementing a value from another workbook

  • Hello,


    I am using this code to get a cell value from a closed workbook...




    How can this code be changed so that it increments the number stored in cell "B1" in the "Number.xlsx" workbook by 1 and places that number in "I10" in the active workbook. Then takes the new number and places it back into cell "B1" (overriding the previous number).


    Does that make sense?

  • Re: Incrementing a value from another workbook


    This code opens the Numbers file and saves the new number in B1 in addition to putting the new number in I10.


  • Re: Incrementing a value from another workbook


    Thank you shknbk2!!


    I have another set of numbers that I want to use this code for, that number set has a letter before the number (B-160000).

  • Re: Incrementing a value from another workbook


    You're welcome.


    Are you additionally asking for more help with the number/letter combination or can you take it from here?

  • Re: Incrementing a value from another workbook


    OK. Slight change to the function. "arg" gets the B1 value (which is a string), and L is set to the part of the text after the hyphen (in case the hyphen is not always in the second position) plus one. B1 is updated with the beginning string of the original value plus the new L.


  • Re: Incrementing a value from another workbook


    Better, yet. This code below combines the two. If there is a hyphen, it is handled one way, and if not, another way.


  • Re: Incrementing a value from another workbook


    Thank you!


    I would never have been able to figure this out on my own.


    The code works great, just does not add the letter and hyphen when it places the number in "I10".

  • Re: Incrementing a value from another workbook


    Well, in that case, use this:


  • Re: Incrementing a value from another workbook


    I am trying to use this code for a number set that does not contain the "-" and I get a run time error highlighting this line in the code...


    Code
    1. l = w.Sheets(sheet).Range(ref).Value + 1


    Any idea on how to fix that?