+ Reply to Thread
Results 1 to 12 of 12

Define contents entire worksheet

  1. #1
    Registered User
    Join Date
    07-08-2014
    Location
    Rotterdam, NL
    MS-Off Ver
    MS Office 2007
    Posts
    10

    Define contents entire worksheet

    This is probably a very easy question to answer (at least, I hope so...), but could anyone tell me how to define the contents of an entire worksheet, regardless of what's in that worksheet? I thought it would be something like below, but that's not working.

    wsContent = Worksheets("wsName").Value

    Thanks!

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define contents entire worksheet

    Please Login or Register  to view this content.
    Last edited by AB33; 07-08-2014 at 10:00 AM.

  3. #3
    Registered User
    Join Date
    07-08-2014
    Location
    Rotterdam, NL
    MS-Off Ver
    MS Office 2007
    Posts
    10

    Re: Define contents entire worksheet

    Thanks for the quick reply, but I still get an error for this line saying Subscript out of range. Do you have any idea how to solve this?

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define contents entire worksheet

    You may not have a sheet name called "wsName" in one of your sheets. Make sure the sheet you are working does not have typo and space.

  5. #5
    Registered User
    Join Date
    07-08-2014
    Location
    Rotterdam, NL
    MS-Off Ver
    MS Office 2007
    Posts
    10

    Re: Define contents entire worksheet

    The code was copied directly from here, only the sheet name has been changed to reflect the name of the actual sheet. There are no differences in the sheet name.

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define contents entire worksheet

    you could use

    Please Login or Register  to view this content.
    Did you define wsContent? It has to be a variant

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

    Re: Define contents entire worksheet

    Is the worksheet actually called 'wsName' or is wsName a variable which holds the name of the worksheet?
    If posting code please use code tags, see here.

  8. #8
    Registered User
    Join Date
    07-08-2014
    Location
    Rotterdam, NL
    MS-Off Ver
    MS Office 2007
    Posts
    10

    Re: Define contents entire worksheet

    To answer both of you here: wsContent has been defined as Object (not entirely sure if that's correct?). wsName is the name of the actual worksheet, it's not a variable. i can't use ActiveSheet as it isn't the sheet that's active at the moment.

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Define contents entire worksheet

    Remove the object, so leave wsContent with out any varaible

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

    Re: Define contents entire worksheet

    Can you post the rest of the code, including any declarations?

  11. #11
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Define contents entire worksheet

    wsContent is a Range Object. Try:

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    07-08-2014
    Location
    Rotterdam, NL
    MS-Off Ver
    MS Office 2007
    Posts
    10

    Re: Define contents entire worksheet

    Guys, I got it working. It turned out that earlier in the macro a different worksheet was opened which was active at the moment. Thanks for the suggestions, I think I was asleep yesterday...

+ 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. Highlight Cell if Contents are elsewhere in entire worksheet
    By Shazz in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 04-02-2013, 07:56 AM
  2. using cell contents as a string to define a folder path
    By RDS in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-13-2012, 04:16 PM
  3. Drop Down List to Copy Entire Contents of Worksheet into Master Worksheet
    By mrmartin in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-14-2011, 10:54 PM
  4. Replies: 0
    Last Post: 05-20-2011, 03:26 PM
  5. Define variables for entire Project
    By Edwood in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2009, 04:24 AM

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