+ Reply to Thread
Results 1 to 6 of 6

Excel VBA .Find issue

  1. #1
    Registered User
    Join Date
    08-11-2015
    Location
    belfast
    MS-Off Ver
    2010
    Posts
    24

    Excel VBA .Find issue

    Hello I have a workbook, that has multiple sheets the sheets are called the following Supervisors 1 , Supervisors 2, Supervisors 3, Supervisors 4, Staff 1, Staff 2, Staff 3, Staff 4 and a sheet called Summary.

    My issue is that when I try to look for Total Supervisors or Total Staff, I get a 'Error code 91 , variable not set'

    I am still new to vba and people on here have been so supportive and helpful so can I ask again for all your help and advice.

    Please Login or Register  to view this content.

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

    Re: Excel VBA .Find issue

    I have not tested it, but you are missing to check if the item exists.
    This line appears to be wrong.

    Sheets(Sheets(x).Name).

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    08-11-2015
    Location
    belfast
    MS-Off Ver
    2010
    Posts
    24

    Re: Excel VBA .Find issue

    When you say i am failing to check the item exists, what do yo mean and how would i check it does exist then, when I run the code I get an error on the same line the cell number may change though.

    Please Login or Register  to view this content.

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

    Re: Excel VBA .Find issue

    There are a number of issues with the code.
    Why are looping twice through a collection of worksheets? It looks like you are nesting the looping over another looping.
    Since you are using sheet's collections, why do you need to use a name? The loop uses an index number to access the sheets. Sheets(x) means 1 and the next sheets(x) would be 2 and so on, so you can just use -Sheets(x), unless of course you are trying to name the sheets.
    If you have an object, then you need to test if the object exists:
    If Not snRow Is Nothing Then
    Otherwise, VBA will complain, it could not find the object.

    Sheets("Summary").Cells(8, rc.Column - 1) = Sheets(Sheets(xc).Name).Cells(snRowC.Row, rc.Column).Value

  5. #5
    Registered User
    Join Date
    08-11-2015
    Location
    belfast
    MS-Off Ver
    2010
    Posts
    24

    Re: Excel VBA .Find issue

    Hello is still come sup with the same error code.

    But when I comment out part of the original code to exclude the staff it will work without an issue but as soon as I include the staff aspect to it it throws the error code up.

    Please Login or Register  to view this content.

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2404
    Posts
    24,784

    Re: Excel VBA .Find issue

    Quote Originally Posted by chrisnash70 View Post
    [INDENT]Hello I have a workbook,
    Your post does not comply with Rule 8 of our Forum Rules: Do not crosspost your question on multiple forums without including links here to the other threads on other forums.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you must provide a link (copy the url from the address bar in your browser) to the cross-post.

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (most other forums have the same rule).

    This thread should have no further responses until a link to the cross-post is added.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ 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. Have issue at work, please help with find nearest point by using VBA or excel fomula
    By robert12345 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2016, 11:19 PM
  2. If(Vlookup(Find Issue in Excel
    By Blackhawks in forum Excel General
    Replies: 4
    Last Post: 03-28-2014, 12:25 PM
  3. IF(Vlookup(Find Excel issue
    By Blackhawks in forum Excel General
    Replies: 1
    Last Post: 03-28-2014, 12:13 PM
  4. [SOLVED] Issue with FIND/REPLACE Excel 2003 VBA
    By dawatcher in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2013, 06:44 PM
  5. Excel 2003 find function help/issue!
    By controlfreak in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 05-20-2009, 06:09 AM
  6. Issue with Excel Find functionality...
    By Jeff W in forum Excel General
    Replies: 3
    Last Post: 04-17-2007, 10:56 AM
  7. [SOLVED] Excel find and replace issue
    By buddyorliz in forum Excel General
    Replies: 3
    Last Post: 06-04-2005, 05:05 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