+ Reply to Thread
Results 1 to 8 of 8

Selecting or determining the active row.

  1. #1
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Selecting or determining the active row.

    I am looking for a way to select the active row. Either row 18 or row 21 depending on which value I want to change. The code I have for row 18 is as follows.
    Please Login or Register  to view this content.
    It just subtracts the amount entered from the total amount of boxes in inventory and sends a copy to the history sheet when the Active X button is pressed. I have added row 21 and will add more rows to sheet 1 later, but I need my code to realize which row I am selected in, so it only makes changes in one row at a time. Nothing I have tried has worked.
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Selecting or determining the active row.

    Please Login or Register  to view this content.
    will return the active row.

  3. #3
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Selecting or determining the active row.

    What if I only want to select the three cells in the row? Cells B18:D18

  4. #4
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Selecting or determining the active row.

    Please Login or Register  to view this content.
    Thanks,
    Solus


    Please remember the following:

    1. Use [code] code tags [/code]. It keeps posts clean, easy-to-read, and maintains VBA formatting.
    Highlight the code in your post and press the # button in the toolbar.
    2. Show appreciation to those who have helped you by clicking below their posts.
    3. If you are happy with a solution to your problem, mark the thread as [SOLVED] using the tools at the top.

    "Slow is smooth, smooth is fast."

  5. #5
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Selecting or determining the active row.

    Please Login or Register  to view this content.
    Can someone tell me why the highlighted part of the code keeps giving me an error message. It says method, range of object failed. When I am in the debugger mode, it is returning the proper value, so it does know which cell value I am asking for. Any help appreciated.

  6. #6
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Selecting or determining the active row.

    You are trying to set the value of a range to R1, which is a range object. Whereas the value of a range is not a range object. So you need either:
    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.
    not, you can also use
    Please Login or Register  to view this content.
    in place of the range(cells( construct.

  7. #7
    Forum Expert Solus Rankin's Avatar
    Join Date
    05-24-2013
    Location
    Hollywood, CA
    MS-Off Ver
    Win7 Office 2010 VS Express 2012
    Posts
    2,655

    Re: Selecting or determining the active row.

    The only other way that would work is if the value of Cells(ActiveCell.Row, 2) is a valid range (doesn't look like thats what you're going for).


    Such as:

    Swks.Range(Cells(ActiveCell.Row, 2).value) where Cells(ActiveCell.Row, 2).value is something like B12.
    Last edited by Solus Rankin; 11-26-2013 at 09:46 AM.

  8. #8
    Forum Contributor
    Join Date
    06-28-2013
    Location
    Green Bay, WI
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Selecting or determining the active row.

    This is the final coding I came up with. Now I will be able to add other items to track on sheet1 as long as they are in the B, C, and D columns. Only the row selected will be active and I did not have to name a specific cell for the subtraction or the copying to the History Sheet.

    Thanks for the help!!

    Please Login or Register  to view this content.
    If you look in module 3, you will see this code and a whole other way to copy and paste to the another sheet.
    Attached Files Attached Files

+ 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 Active Sheet
    By JosueDG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-13-2011, 06:16 PM
  2. [SOLVED] Determining last active cell in a protected worksheet
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2006, 12:45 PM
  3. selecting the currently active column
    By armagan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2006, 07:53 AM
  4. Selecting only active range
    By oz_saar in forum Excel General
    Replies: 2
    Last Post: 08-11-2005, 03:31 AM
  5. Selecting the active row
    By el_grimley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-05-2005, 04:19 AM

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