+ Reply to Thread
Results 1 to 4 of 4

For Next with ws.Name

  1. #1
    Forum Contributor
    Join Date
    05-26-2004
    Location
    Halifax, UK
    MS-Off Ver
    Office 2016
    Posts
    260

    For Next with ws.Name

    I'm having a problem with the following code:

    Please Login or Register  to view this content.
    However on execution it gives a "Run-time error 13, Type mismatch" message. The problem is with the line:

    Please Login or Register  to view this content.
    I've tried changing it, simplifying, but it still gives the same error, e.g. changing it to:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Etc etc. But none of these work and I can't see why. There is definitely a worksheet with the name "4" so when the var dcm_id is equal to 4 it should find the worksheet with this name and *do stuff*.

    Anyone got any ideas?

    Cheers
    Rob
    Last edited by TheRobsterUK; 06-05-2014 at 07:51 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
    I wouldn't have expected it to be a problem but worksheet names are strings, so perhaps comparing a string to in integer is causing the type mismatch.

    If that is the problem try declaring dcm_id as String.
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    05-26-2004
    Location
    Halifax, UK
    MS-Off Ver
    Office 2016
    Posts
    260

    Re: For Next with ws.Name

    Yeh that seems to have made the problem go away, thanks!

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

    Re: For Next with ws.Name

    Maybe:

    Please Login or Register  to view this content.

+ 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