+ Reply to Thread
Results 1 to 5 of 5

Importing .BAS to Sheet Object... NOT Class Module?

  1. #1
    Registered User
    Join Date
    08-23-2012
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Unhappy Importing .BAS to Sheet Object... NOT Class Module?

    Hi Guys,

    Been trawling though all the posts and appear to have found something that hasn't already been answered (long shot I know!).

    Here's my full code:

    Please Login or Register  to view this content.
    I am copying a load of filtered data to separate worksheets for use by different sales people... They're bound to try and break things, so their final files have protection enabled... They need to be able to insert extra rows of data, so I have built a macro that unprotects and copies various formulas to the inserted row when it detects a row is inserted. Here's the code for the macro I wish to insert into the sheet object:

    Please Login or Register  to view this content.
    You can see in the "copy sheet macro" of my first code that I am copying the macro from Sheet6... I then want to paste it into Sheet1 of the new workbook:

    Please Login or Register  to view this content.
    Unfortunately, this creates a class module which means it doesn't activate when a row is inserted on Sheet1. When I try and define the VBComponents as Sheet1 the macro breaks stating "Object doesn't support this property or method".

    Thanks for any help you guys can give!!!

    crabby

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Importing .BAS to Sheet Object... NOT Class Module?

    It is simpler to use a template workbook with the code already in place.
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    08-23-2012
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Importing .BAS to Sheet Object... NOT Class Module?

    So, it's really that hard? I'll change my code to use a template, but would love to understand why it's so easy to export from any object but so hard to import?

    Thanks,

    crabby

  4. #4
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,996

    Re: Importing .BAS to Sheet Object... NOT Class Module?

    Because the worksheet already has a code module. The Import function only creates new modules - it won't replace an existing one.

  5. #5
    Registered User
    Join Date
    08-23-2012
    Location
    Cambridge, England
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: Importing .BAS to Sheet Object... NOT Class Module?

    Well.. That's me learnt!

    I simply produced a blank sheet in my master document with the macro embedded and changed my formula to this:

    Please Login or Register  to view this content.
    Thanks,

    crabby

+ 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] Member already exists in an object module form which this object module derives error
    By Sc0tt1e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-01-2014, 03:14 AM
  2. [SOLVED] ComboBox class .AddItem filled in class module
    By Jacques Grobler in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-03-2012, 05:48 AM
  3. Replies: 1
    Last Post: 08-30-2011, 02:23 AM
  4. [SOLVED] To access a previous object via class module
    By Pierre Archambault in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-31-2005, 02:51 AM
  5. Exporting / importing class module
    By ydiabolo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-10-2005, 12:24 PM

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