+ Reply to Thread
Results 1 to 6 of 6

Set Worksheet Range

  1. #1
    Registered User
    Join Date
    10-13-2009
    Location
    Great Falls, Montana
    MS-Off Ver
    Excel 2007
    Posts
    32

    Set Worksheet Range

    I have a problem declaring a range. If I use
    Please Login or Register  to view this content.
    it will give me the range of the wrong worksheet. If I try to force the correct worksheet, I get "Application Defined or Object Defined error".
    Could someone please look at "Employee List" Worksheet_Change sub in the section "EnterOnSubList:" and tell me what I'm doing wrong? Any other comments of my code would also be appreciated.
    Thanks, Frank
    Attached Files Attached Files
    Last edited by Frankf; 12-07-2010 at 04:12 PM.

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

    Re: Set Worksheet Range

    To specify the sheet:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  3. #3
    Registered User
    Join Date
    10-13-2009
    Location
    Great Falls, Montana
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Set Worksheet Range

    Thanks for looking at this romperstomper. I edited it just as you suggest
    Please Login or Register  to view this content.
    But I get the same error 1004 "Application or Object defined error". on the line Set.....
    Do you have any other ideas what might be triggering this error? I really appreciate your help.

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

    Re: Set Worksheet Range

    You missed the two periods before the Cells calls that are in my post.

  5. #5
    Registered User
    Join Date
    10-13-2009
    Location
    Great Falls, Montana
    MS-Off Ver
    Excel 2007
    Posts
    32

    Re: Set Worksheet Range

    Thank you so much romperstomper! You have no idea how frusterating debugging has been, or how long I've worked on this. Can you recommend a reference that can clarify when the period is needed, or why? It may save a lot of heartburn later.

  6. #6
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,298

    Re: Set Worksheet Range

    The periods are needed for the Cells and Range calls to make them 'belong' to the Sheets("Sub Contractor List") object. If you didn't use the With...End With, then you would have to write:
    Please Login or Register  to view this content.
    As you can see, the With statement makes it a lot neater.

+ 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