+ Reply to Thread
Results 1 to 11 of 11

Exclude 2 sheets and Run the Macro

  1. #1
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Exclude 2 sheets and Run the Macro

    Hi All,

    I have a code which will do a text to column on the sheets. I will run this on every tab. the tab name varies but the data will be similar and starts only from A3 and will not have any blanks. Can any one suggest or add a line to do the same job on all sheets in the file except from 2 tabs which will be "Macro" and "File".

    Below is the Code for reference.

    Sub TexttoCol()
    '
    ' TexttoCol Macro
    '

    '
    Range("A3").Select
    Range(Selection, Selection.End(xlDown)).Select
    Selection.TextToColumns Destination:=Range("A3"), DataType:=xlFixedWidth, _
    FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(20, 1), Array(32, 1), Array(40, 1), _
    Array(53, 1), Array(61, 1), Array(72, 1), Array(85, 1), Array(95, 1), Array(105, 1), Array( _
    115, 1), Array(130, 1), Array(145, 1), Array(166, 1), Array(207, 1)), _
    TrailingMinusNumbers:=True
    End Sub

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

    Re: Exclude 2 sheets and Run the Macro

    Perhaps.
    Please Login or Register  to view this content.
    PS Can you add code tags when posting code?
    If posting code please use code tags, see here.

  3. #3
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Thanks Norie,

    But seems like there is some thing error at end. I have attached a sample for your reference.
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Hi Norie, and I think the code is not passing after running from one tab to another. can do add a line which will run on all the tabs but not on Macro and File tab.

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

    Re: Exclude 2 sheets and Run the Macro

    The code I posted will run on all sheets apart from the two named 'File' and 'Macro', and that's what it does in the sample workbook you attached.

  6. #6
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Sorry to bother you.. I am trying on the attached file but it stops after running in the first tab. Not sure is it only for me?
    Attached Files Attached Files

  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: Exclude 2 sheets and Run the Macro

    Just a typo.
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Thank you so much.. runs Perfectly

  9. #9
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Hi Norie- Small change the macro wont if the sheet does not have any data.. Can we just add one more line which will jump if it finds any empty sheet

  10. #10
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Hi Norie- is it possible to jump the macro if it finds a blank or no data sheet

  11. #11
    Forum Contributor
    Join Date
    06-25-2013
    Location
    India
    MS-Off Ver
    Excel 2016
    Posts
    123

    Re: Exclude 2 sheets and Run the Macro

    Can any one add a line which would jump to next sheet if a macro finds a blank sheet.

    Thank you

+ 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. Need to run this macro on all sheets except those I'd like to exclude
    By Adam1027 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2014, 06:03 PM
  2. Need to change code that loops all sheets TO exclude some sheets.
    By sherrie777 in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 04-10-2010, 05:29 PM
  3. Exclude some sheets
    By maxwell13 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-03-2007, 01:10 AM
  4. [SOLVED] Exclude Sheets from Macro
    By Lambtwo in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-17-2006, 05:25 PM

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