+ Reply to Thread
Results 1 to 3 of 3

Creating a Separate Logging Workbook

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42

    Creating a Separate Logging Workbook

    What I have is an Excel spreadsheet that allows users to access some information about an item by typing in its associated part number. What has been requested is an additional feature that is an "Add to List" button. This button would take the item currently being viewed and add it to a separate workbook, the idea being that as users browse through information, it would automatically record the parts that they want to remember in a separate file.

    In the sub for this button, what I am trying to do is to declare the target workbook to add the item to and assign it to a variable. Then, if an error occurs in that assignment, the workbook clearly does not exist and must be created. I thought this was the best way to create the file such that I didn't create a new one for each new item and such that I could reference it any time the button was called without having a global variable. I'm also perfectly open to other suggestions if this wasn't the best way to approach it.

    My code thus far is below. The problem is that, as expected, an error occurs when I try to set listbook. However, instead of using that error to get into the for loop, it just throws a "Subscript out of range" error and stops the program. Clearly I am not understanding how to appropriately use the IsError function, and any help in implementing this would be greatly appreciated. Thanks.

    Please Login or Register  to view this content.

  2. #2
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42
    I finally stumbled across a function online that supposedly checks to see if a file by some name is open.

    Please Login or Register  to view this content.
    This seems to work, at least as far as I have been able to test it so far. However, I am running into problems when trying to create the file if it doesn't exist. Here's my code:

    Please Login or Register  to view this content.
    However, I get an error on the Workbooks.Add("List.xls") line saying that the file counld not be found. I am confused - I thought this command was supposed to create a new file. Why then would I be getting this error, and how can I get around it?

  3. #3
    Registered User
    Join Date
    07-09-2008
    Location
    Panama City, FL
    MS-Off Ver
    2007
    Posts
    42
    Problem solved.

    Please Login or Register  to view this content.

+ 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