+ Reply to Thread
Results 1 to 5 of 5

vba code for len text not working when sheet is not active

  1. #1
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    vba code for len text not working when sheet is not active

    How to make the code below works when the macro is triggered on another sheet in the same workbook

    The sheet tab is workings but do not highlight text when more than 8 digits or less than 7 digits .
    When triggered on active sheet without those in red , it works , but triggered on another sheet shows no response at all when those in red is inserted


    Please Login or Register  to view this content.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,857

    Re: vba code for len text not working when sheet is not active

    If I understand correctly, you want this code to work on any sheet in a workbook and not just the specified "Workings" sheet. If this is the case, then comment out the With and End With statements and it should work on any open worksheet.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: vba code for len text not working when sheet is not active

    No , What I want to do is to trigger the macro from another sheet in same workbook

    Suppose I have my macro button on sheet tab call trigger all, the above macro should look on sheet "workings" and check for + 8digits and less -7 digits and highlight as per specifications

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2404 Win 11 Home 64 Bit
    Posts
    23,857

    Re: vba code for len text not working when sheet is not active

    try the following.

    I have added periods in from of the cells as this is required when you use the With object

    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    02-11-2014
    Location
    mauritius
    MS-Off Ver
    MS365
    Posts
    1,086

    Re: vba code for len text not working when sheet is not active

    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. Replies: 2
    Last Post: 05-17-2016, 12:23 PM
  2. (Urgent Req) VBA code required to select a sheet just before a active sheet
    By mchilapur in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2015, 12:03 PM
  3. Replies: 20
    Last Post: 01-11-2014, 05:39 AM
  4. [SOLVED] Active sheet shifts back to original sheet when executing code
    By pcdog in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 10-22-2012, 11:07 AM
  5. [SOLVED] How to get (range)macro to always run code on a specific sheet regardless of active sheet?
    By JTwrk in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2012, 04:33 PM
  6. Code not working unless sheet is active
    By WAW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-09-2010, 12:18 PM
  7. Code to print columns with active rows not working
    By debbiesh in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-11-2009, 05:14 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