+ Reply to Thread
Results 1 to 15 of 15

Grabbing the current row number

  1. #1
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Grabbing the current row number

    I have quite a few rows with a checkbox on each row. When the checkbox is clicked I perform a few actions within a few columsn on that row. Instead of hardcoding each row number into the code, is there a way to grab the row number that the checkbox is located?

    Here's what I have now on row 205, for example.

    Please Login or Register  to view this content.
    And it'd be nice to put that action on each checkbox, but without hardcoding the row number and keeping the columns (C and I) the same.

    Thanks!

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Grabbing the current row number

    Can you post the file?

  3. #3
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    Attached is an example of what I'm doing.
    Attached Files Attached Files

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Grabbing the current row number

    if it's a forms checkbox
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Grabbing the current row number

    I am not smart enough to write a code to locate the row where the check box is located, but if you talking about the last row that contains text, I can certainly help you with that.

  6. #6
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    EDIT: Sort of. An active cell is the cell with the focus, not necessarily one you just clicked in.

    Found it!

    You call:

    Please Login or Register  to view this content.
    Last edited by kid_epicurus; 04-27-2012 at 04:08 PM.

  7. #7
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    TopLeftCell.Row works great. However, a quick question. Currently my functions on each checkbox looks a little like this...

    Please Login or Register  to view this content.
    What can be used to substitute the checkbox name? In this case "Ach_CorrectFirmware". (Something along the lines of This in other languages.)

  8. #8
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Grabbing the current row number

    you're using activex controls-you'd need a class to do that. forms controls are simpler and more stable-you can just assign the same macro to all of 'em at once.

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Grabbing the current row number

    I would agree with JP about not using ActiveX controls on a worksheet, but I wouldn't use Forms toolbar checkboxes either. Marlett checkboxes are easy to mechanize, and you don't have to worry about where objects are on the drawing layer, because they are just cells.
    Entia non sunt multiplicanda sine necessitate

  10. #10
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    Quote Originally Posted by shg View Post
    I would agree with JP about not using ActiveX controls on a worksheet, but I wouldn't use Forms toolbar checkboxes either. Marlett checkboxes are easy to mechanize, and you don't have to worry about where objects are on the drawing layer, because they are just cells.
    Never heard of Marlett checkboxes and can't seem to locate them in Excel. Where can I find the control?

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: Grabbing the current row number

    It's not a control. Search the forum for numerous examples, and post back if you get stuck.

  12. #12
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    Quote Originally Posted by JosephP View Post
    you're using activex controls-you'd need a class to do that. forms controls are simpler and more stable-you can just assign the same macro to all of 'em at once.
    How can I generically call the checkbox that's being clicked using a common function? For example, if I want to make a function to highlight the row of the checkbox I don't want to hardcode each row number or a separate function for each box.

  13. #13
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Grabbing the current row number

    HTH
    Regards, Jeff

  14. #14
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: Grabbing the current row number

    if you replace the activex controls with Forms versions, you can assign them the same macro and then use the code I posted before

  15. #15
    Registered User
    Join Date
    04-19-2012
    Location
    Knoxville, TN
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Grabbing the current row number

    Quote Originally Posted by JosephP View Post
    if you replace the activex controls with Forms versions, you can assign them the same macro and then use the code I posted before
    Gotcha. Forgot about that post. Thank you.

+ 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