+ Reply to Thread
Results 1 to 5 of 5

Reference Error Macro VBA

  1. #1
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Reference Error Macro VBA

    Hi, I messed up! hehe

    Im not an VBA expert which you will see.

    I was looking for a code to rewrite a macro from another macro. I found a bit of code that i thought could do it for me but now im afraid it messed up references in other macros in the same workbook! After I did run the macro which actually changed | to ; in my module Departments this and some other macros reads from the wrong sheet. Nothing has changed in them though from what i can see.

    This is the code:
    Please Login or Register  to view this content.
    --------------------------------------------------------------------------------

    Here is the code that does no longer gets data from "DEPT". Probably could do this alot better but atleast it worked at first.
    Now it gets data from another sheet. No longer from "DEPT"
    Please Login or Register  to view this content.
    Last edited by britzer; 12-16-2013 at 11:39 AM.

  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: Reference Error Macro VBA

    Which part of the code is referencing the wrong sheet?

    By the way, why are you using code to change one character in a sub?

    If you wanted the sub to work with different delimiters, eg ; or |, it could be rewritten to take the delimiter as an argument.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Reference Error Macro VBA

    Thanks alot for the fast answer!

    The thought is to have a button for the user to change vertical bar separator in .dat file to ; separator. I could probably do it directly in the .dat file but havent found out how to do it so i tried this.

    The second part is supposed to read from the sheet "DEPT" which is hidden and Print in a .dat file from start of sheet "DEPT" to end. Before using the first code it fetched data from "DEPT" and now it fetches data from sheet "XX". I dont understand why!?

    As I mentioned and you probably notice im not that experienced to VBA. I dont know how to rewrite to take the delimiter as an argument.

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

    Re: Reference Error Macro VBA

    How does this work?
    Please Login or Register  to view this content.
    You call it like this, passing the required string for the delimiter.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-06-2013
    Location
    Swe
    MS-Off Ver
    Excel 2007
    Posts
    26

    Re: Reference Error Macro VBA

    Thanks a bunch. Its now working. I think =)

+ 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. Excel macro (compile error. syntax error.) error
    By salar_younis in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-06-2014, 06:11 AM
  2. Windows 8, Excel 2013 and Project 2010 - Reference Error in Macro
    By microsoftexcel007 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-01-2013, 06:23 PM
  3. Print Macro / module error & Update / Clear Macro error
    By mal.b.graham in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 09-28-2012, 06:40 PM
  4. Replies: 1
    Last Post: 04-30-2012, 12:07 PM
  5. Macro to Reference Column Next to Current Reference
    By dolphinv4 in forum Excel General
    Replies: 2
    Last Post: 04-11-2005, 04:06 AM

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