+ Reply to Thread
Results 1 to 8 of 8

Identify Row Number based on Value in a cell and use that Row number in a Macro

  1. #1
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Identify Row Number based on Value in a cell and use that Row number in a Macro

    I have Sheet with 40 employees who each proposes their work schedule, so I have to give each Employee access to the same sheet and want highlight and unlock only those cells that specific employee can use.

    Each employee has to login from a drop-down (sourced from Sheet.Employee Master), so their unique Employee Number is in "A13" of Sheet.LOGIN

    Can I identify the ROW number and then use that ROW number in a macro to highlight and unlock specific Range of Cells in Sheet.PROPOSED SCHEDULE?
    ---where "Sheet.LOGIN("A13") = (the value in the cell Col A:"row" of Sheet.PROPOSED SCHEDULE)


    I have attached a scaled down version of the Workbook.


    Following code is scaled down-- this is for Employee 02 who appears on ROW 16 of the sheet. (macro is same for each employee, just uses a different row)

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by johnnywinter; 01-28-2009 at 09:41 PM.

  2. #2
    Forum Contributor mewingkitty's Avatar
    Join Date
    09-29-2008
    Location
    Fort McMurray, Alberta, Canada
    MS-Off Ver
    Excel 2003
    Posts
    949

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Cells(x, y).Row

    If you determine that cell x, y meets your criteria, that there will return the row number associated with that cell, you could use that as an integer in the rest of your code, IE

    if cells(x, y) = whatever condition
    a = cells(x, y).row
    cells(a, y) = whatever you want to do to that cell.

    Does that give you any ideas?
    =IF(AND(OR(BLONDE,BRUNETTE,REDHEAD),OR(MY PLACE,HER PLACE),ME),BOW-CHICKA-BOW-WOW,ANOTHER NIGHT ON THE INTERNET)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Hello johnnywinter,

    I revised your code not to use "Selection"
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Leith:

    When I run your code I get following Error Message:

    Compile Error "End IF without block IF"


    Thanks

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Hello johnnywinter,

    Maybe it didn't copy over correctly. I just tested this code and it compiled OK.
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Leith,

    Thanks, guess I had pasted it wrong. I have triple checked and it is posted exact.


    Now your code stops on last line below (.colorIndex = 35) with the error message:

    "Run Time Error "438" Object doesn't support this property or method"



    Please Login or Register  to view this content.
    All sheets are unprotected and all cells are in the above range are unlocked. I am using Excel 2003.

    Thanks,

  7. #7
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Hello johnnywinter,

    I think I need to see your workbook. Can you post a copy of it for review?

  8. #8
    Registered User
    Join Date
    08-21-2007
    Posts
    90

    Re: Identify Row Number based on Value in a cell and use that Row number in a Macro

    Leith,

    It is working perfectly. Here is the final code.

    Thanks for all yoru help and patience.

    JW


    Please Login or Register  to view this content.
    Last edited by Leith Ross; 01-28-2009 at 06:32 PM. Reason: Corrected Typo on Code Tag

+ 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