+ Reply to Thread
Results 1 to 5 of 5

Selecting a particular cell for all worksheets

  1. #1
    Registered User
    Join Date
    02-07-2019
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    2

    Selecting a particular cell for all worksheets

    Dear all, my first time posting here.

    I have a workbook containing about 50 different sheets. I use macros to lock and unlock all the sheets. All the sheets are protected, and I want the users of the sheets to have a particular cell selected for them. Just wondering why I'm getting a 1004 error everytime I insert this piece of code in.

    Problematic Code:
    For Each s In ActiveWorkbook.Worksheets
    s.cells(5,2).select
    Next

    Temporary band-aid solution:
    For Each s In ActiveWorkbook.Worksheets
    s.Activate
    ActiveSheet.Cells(5, 2).Select
    Next

    What am I getting wrong? Thanks in advance for answering

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,340

    Re: Selecting a particular cell for all worksheets

    You can't select a cell if a sheet isn't active. Try Application.GoTo
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Selecting a particular cell for all worksheets

    Try this
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  4. #4
    Registered User
    Join Date
    02-07-2019
    Location
    Australia
    MS-Off Ver
    Office 365
    Posts
    2

    Re: Selecting a particular cell for all worksheets

    Thanks all, appreciate it. added reps!

  5. #5
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,340

    Re: Selecting a particular cell for all worksheets

    You're welcome. Thanks for the rep.

+ 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. selecting between worksheets to run codes
    By freak11 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-14-2014, 03:37 PM
  2. Replies: 0
    Last Post: 05-05-2011, 05:18 AM
  3. Selecting worksheets using an IF statement?
    By bryanr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-27-2009, 07:13 PM
  4. Selecting and Copying a Cell or a Range of Cells from One or More Files or Worksheets
    By Tyler Peco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-27-2008, 03:55 PM
  5. Replies: 3
    Last Post: 11-10-2007, 09:34 AM
  6. Selecting across worksheets
    By JMS in forum Excel General
    Replies: 1
    Last Post: 07-14-2005, 06:05 PM
  7. [SOLVED] Selecting WorkSheets
    By Jordan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-25-2005, 04:06 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