Results 1 to 13 of 13

Code Gives error if I run it from Module but works fine when run it from This Worksheet

Threaded View

VKS Code Gives error if I run it... 05-17-2013, 05:25 AM
cytop Re: Code Gives error if I run... 05-17-2013, 05:34 AM
:) Sixthsense :) Re: Code Gives error if I run... 05-17-2013, 05:38 AM
VKS Re: Code Gives error if I run... 05-17-2013, 05:58 AM
:) Sixthsense :) Re: Code Gives error if I run... 05-17-2013, 06:04 AM
Norie Re: Code Gives error if I run... 05-17-2013, 06:07 AM
VKS Re: Code Gives error if I run... 05-17-2013, 06:35 AM
Norie Re: Code Gives error if I run... 05-17-2013, 06:40 AM
VKS Re: Code Gives error if I run... 05-17-2013, 07:05 AM
VKS Re: Code Gives error if I run... 05-17-2013, 07:29 AM
:) Sixthsense :) Re: Code Gives error if I run... 05-17-2013, 07:36 AM
Norie Are you sure the code is... 05-17-2013, 08:26 AM
VKS Re: Code Gives error if I run... 05-17-2013, 01:18 PM
  1. #1
    Forum Contributor
    Join Date
    11-11-2012
    Location
    Muscat, Oman
    MS-Off Ver
    Office 365
    Posts
    522

    Code Gives error if I run it from Module but works fine when run it from This Worksheet

    Hello Experts,
    I have a code below to delete few unwanted sheets and keep the sheets where I have SMRY as a part of the sheet name. This code works fine if I put it in This Worksheet. I get runtime error if I put it in module and try to operate the code from there. Tried changing the name to Sub XXX still got the error.
    From module it gets stuck at the line below
    Ws.Delete
    and the full code is
    Sub Delete_Unwanted_Worksheets()
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Sheets
    Application.DisplayAlerts = False
    If Not ws.Name Like ("*SMRY*") Then
    ws.Delete
    End If
    Next
    Application.DisplayAlerts = True
    End Sub
    Please advise. Best Regards/VKS
    Last edited by VKS; 05-17-2013 at 02:12 PM.

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