+ Reply to Thread
Results 1 to 8 of 8

Help with code to automatically fill in external workbook

  1. #1
    Registered User
    Join Date
    02-16-2018
    Location
    Edmonton, Canada
    MS-Off Ver
    Office 365
    Posts
    30

    Help with code to automatically fill in external workbook

    Hello All,

    The following is some code I have put together to get a packing slip template I am building, to automatically copy some of the data once filled in over to an external workbook. This will allow our shippers to fill in the sheet and then have the external sheet be a running log of all completed packing slips. I keep getting "variable not defined".

    Some help please

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Help with code to automatically fill in external workbook

    Your missing this one.

    Please Login or Register  to view this content.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with code to automatically fill in external workbook

    To help with things like this, put this at the top of the code module:

    Please Login or Register  to view this content.
    Then in the VBEditor, go to DEBUG > Compile VBAProject, it should highlight any undeclared variables for you.

    When I did that it point out the RowCount variable is not listed in your Dims.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  4. #4
    Registered User
    Join Date
    02-16-2018
    Location
    Edmonton, Canada
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Help with code to automatically fill in external workbook

    Thanks for the help, but I am still getting an error indicating the subscript is out of range. My Packing slip template has 4 sheets whereas my example file I included only had 1. Could this cause the error?

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with code to automatically fill in external workbook

    subscript out of range in VBA (at least for me) is always an object I'm trying to address that is named incorrectly in my code or a variable. DEBUG and look at the highlighted line of code and spot the named objects (Sheet names, workbook names, object names) and variable in that line of code that are related to object names. The problem will be in there.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,169

    Re: Help with code to automatically fill in external workbook

    Hello Elliot...

    Fantastic Journey you on...VBA rocks!!!
    Play around with this slight simplification...Easy to understand...Baby steps
    Put this code in Packing Slip Example and save file as a Macro Enabled File...
    Change path to suite...


    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  7. #7
    Registered User
    Join Date
    02-16-2018
    Location
    Edmonton, Canada
    MS-Off Ver
    Office 365
    Posts
    30

    Re: Help with code to automatically fill in external workbook

    Still getting subscript out of range and it always highlights the current worksheet. Ill try to play around with it some more to see what is happening but if anyone else has any ideas...

  8. #8
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Help with code to automatically fill in external workbook

    TIP of the day: Sometimes when we name our worksheet tabs, we accidentally put an extra space at the end, invisible to the eye when done, but forever a "mismatch" when VBA tries to address sheets by name without that hidden space in the code. Worth a look.

+ 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. [SOLVED] Automatically open a workbook and update external links
    By billj in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-10-2016, 11:56 AM
  2. automatically close external workbook with a macro
    By drobinson782001 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-04-2013, 04:37 PM
  3. [SOLVED] Automatically open and close external workbook for indirect function
    By Groovicles in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 12-03-2013, 01:49 PM
  4. automatically incrementing a formula relating to an external workbook
    By DaveLearner in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-02-2012, 06:05 AM
  5. automatically incrementing a formula relating to an external workbook
    By DaveLearner in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-25-2012, 04:07 AM
  6. code the following - down list to automatically fill table
    By blue_sky_70 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2008, 09:21 PM
  7. Repost:Automatically inserting a row in external workbook
    By 50pingviner in forum Excel General
    Replies: 3
    Last Post: 12-28-2005, 03:40 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