+ Reply to Thread
Results 1 to 7 of 7

Returning Row Number

  1. #1
    Registered User
    Join Date
    02-26-2011
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    5

    Angry Returning Row Number

    I need vb to return the row number for the row containing my macro. For example, row 10 would return a 10, row 14 would return 14. All I can find is how to return the active row.

    I do not want the active row.

    This has got to be simple, but I can not find anything except the active row.

    This is the foundation of something much bigger, but I can not even take the 1st step w/o this simple solution.
    Last edited by Bubba_OH; 02-26-2011 at 06:49 PM.

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Returning Row Number

    What do you actually mean by,
    "row number for the row containing my macro".

    Surely your macro is in a code module rather than in a worksheet.
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    02-26-2011
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning Row Number

    Yes, my code is in a module. I am new to Excel coding/terms, but not to coding in general.

    If I make a function called MyFunction(), and I put it in cell C13 ( =MyFunction() ), I need the vb code to determine that it is row 13.

    Again, this is just the starting point. Based on the solution I need, I will use offsets to reverse search through prior cells to make decisions.

  4. #4
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Returning Row Number

    Please Login or Register  to view this content.
    It depends on exactly what you are intending to do but you do know that udf (User Defined Functions) are limited in there interaction with the worksheet and objects.

  5. #5
    Registered User
    Join Date
    02-26-2011
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning Row Number

    Please Login or Register  to view this content.
    Appears to be what I needed. I think I am good to go. Now I need to do things based on that as a starting point.

    Thanks!

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Returning Row Number

    If you put in C13

    =Row()

    The value will be 13. So why do you need MyFunction?

    How do you expect the rest of your code to use that information?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  7. #7
    Registered User
    Join Date
    02-26-2011
    Location
    Ohio
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Returning Row Number

    My worksheet has data in a parent, child, grandchild relationship. This is not something that should normally be done in Excel, but for my purposes, it is what I want. I need to make different calculation depending on where the data is in that relationship.

    Maybe this is not the best way to do this, but based on how the data is entered, this should work well. My data is limited, so it will not get out of control.

+ 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