+ Reply to Thread
Results 1 to 2 of 2

Same Macro, Same Variable, Different Values on Different Machines

  1. #1
    Registered User
    Join Date
    08-15-2012
    Location
    Springfield
    MS-Off Ver
    Excel 2010
    Posts
    2

    Same Macro, Same Variable, Different Values on Different Machines

    Hello, everyone,

    I have an interesting problem. I wrote a macro a few weeks ago and it appeared to work fine for all the users who need to run it. But yesterday, the primary user ran it and the macro failed because one of the variables took on an incorrect value during execution. The error message is Run-Time Error '5': Invalid Procedure Call or Argument.

    The macro captures the last column in the header row and strips away the absolute reference dollar sign and the cell number ("1" in this case) and leaves only the column letter behind. Later in the procedure this column letter is used to set a range to a variable.

    The problem is this: When I run the macro, the column letter comes in as a single alpha character. When the user having the issue runs the macro, the variable is populated with a RANGE REFERENCE instead. So mine comes in as "C". Hers comes in as "C:C". The macro still removes the cell number from the reference and the "$" from the absolute references, but the initial value from her machine is "$C1:$C1" instead of just "$C1" (it may actually be "$C$1:$C$1"; if that matters I'll find out for certain and update the post).

    So my question is, what would cause one machine (I tested with another, and with mine, and of the three only the one behaves this way) to assign the value of that variable that way? Is there a setting somewhere which can be adjusted to correct this? Also, just to be thorough, I tried to build an IF...THEN statement to accommodate the range value, but it still failed for this particular user. And I have NO idea what's going on.

    Any and all help much appreciated.

    Warm regards and have a great day.

  2. #2
    Registered User
    Join Date
    08-15-2012
    Location
    Springfield
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Same Macro, Same Variable, Different Values on Different Machines

    Okay, I've solved this. Turns out, there are other users having the same problem with this macro, and it comes down to whether the user's Excel opens with three initial spreadsheets or just one in the workbook.

    The macro creates a new workbook from sheets it's generating in other parts of the code. When it's finished, the new workbook has the four (4) tabs the macro creates, AND the three initial sheets from the new workbook. So the three sheets, being without the headings the macro searches for, renders an error when the column can't be found.

    To solve it, I've added a routine to remove the initial, unnamed sheets from the new workbook. That should take care of it.

    Thanks for looking anyway, and have a great day.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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