+ Reply to Thread
Results 1 to 15 of 15

Copying Data From Closed Workbook

  1. #1
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Copying Data From Closed Workbook

    Hi Guys,

    Havinig a few niggling little troubles...

    trying to run some code as a workbook is opened, basically, it opens a workbook, copies a number from it, pastes it into a cell in the original workbook, adds "1" to it, then calls another macro to export the new number to the cell in the workbook it was copied from...

    heres what i have:
    Please Login or Register  to view this content.
    now i know this code works, because i copied and pasted it from another workbook that i created that does the same thing, and it works perfectly.

    when i try to run it, it come up with the infamous "Run-timer error '13': Type Mismatch" error... anyone have any ideas as to why? its doing my head in

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    Where do you get the error in the code and where's the code for GetRange?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    i dont know where the error is... its not highlighting anything. nothing at all. hence why im here, i can normally figure it out through a few trial and errors...

    Please Login or Register  to view this content.
    and yer the code for GetRange would help :\ my bad! i alays forget about that bit!

  4. #4
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    i dont know where the error is... its not highlighting anything. nothing at all. hence why im here, i can normally figure it out through a few trial and errors...

    Please Login or Register  to view this content.
    and yer the code for GetRange would help :\ my bad! i alays forget about that bit!

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    When you get the error, which I think happens here by the way, what's in G6 on Sheet1?
    Please Login or Register  to view this content.
    I ran the code and ended up with #REF! in G6.

    The reason I ended up with that is probably because I don't have a workbook called 'Q_Numbers.xlsx' stored in \\mp-sbs-01\storage\Blank Forms\DataBases\.

    So it might be worth checking if the filename and path are correct and accesible.

  6. #6
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    Right cell G6 is an empty cell... its for a sequential Purchase Order number, hence the adding "1" to the value.
    thats what i keep getting the #Ref! after its thrown up the type mismatch error...

    but like i said, it works in another workbook... EXACTLY the same code... same locations and everything! it really is a strange one.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    It's the #REF error that's causing the type mismatch error, it's there before you try and increment.

  8. #8
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    is there anyway i can troubleshoot whats going on?

  9. #9
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    right it works!
    all i did was change "\\mp-sbs-01\storage\Blank Forms\DataBases\" to "\\mp-sbs-01\storage\" and put a copy of Q_Numbers.xlsx there... very strange, maybe it just doesnt like long network paths??

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    I don't like them either.

    Have there been any changes in the network?

    Can you manually open the file in \\mp-sbs-01\storage\Blank Forms\DataBases\?

  11. #11
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    no i dont like long paths... maybe ill just create another share? or maybe ill just leave it as is and working? haha!
    no there was no changes in the network at all... my worrie now is, will other people get the same errors when using it on dfferent machines? everyone has access to the network share so it shouldnt be a problem?
    yer i can manually open the file through the "run" command... i really dont understand it...

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    Do you need to take the Purchase Order number from that file?

  13. #13
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    yer i do... when generating a new order, it gets the number from the Q_Numbers file, pastes it to G6 in the purchase order, adds 1, then pastes that number back to Q_Numbers, making the next purchase order thats created, the next number... if that makes sense?
    why is there an easier way to do this? am i making it too complicated?

  14. #14
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Copying Data From Closed Workbook

    Makes perfect sense, just wondered if there was another approach which would avoid having to get the value from the workbook.

  15. #15
    Registered User
    Join Date
    02-12-2013
    Location
    Essex
    MS-Off Ver
    Office Professional Plus 2010
    Posts
    21

    Re: Copying Data From Closed Workbook

    i figured it would be best, as about 3 different people will want to create them, therefore the number needs to be centralised... damn this programmings hard stuff hahaa!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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