+ Reply to Thread
Results 1 to 4 of 4

Trying to mimic row() in custom VBA function

  1. #1
    Registered User
    Join Date
    09-08-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2010
    Posts
    2

    Trying to mimic row() in custom VBA function

    I am new to VBA custom functions so there may be an obvious solution to this, but there may not be. Looking for some pointers... here goes!

    I am currently creating a custom function that is calculated based on the row of each cell. If I was using the built in worksheet functions, I could enter
    =row()
    into a cell, say A1, and I will get the row of that cell, in this case 1. If I drag this formula down to B1, the formula will give a value of 2.

    Is there a way to mimic this functionality in VBA? I initially tried using the below code, but found that the code does not work when dragging the formula down to other cells because the active cell is unchanged. The value only changes if I click in the cell B2 (thus changing the Active Cell) then enter the formula. Thanks in advance for any help you can give!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,247

    Re: Trying to mimic row() in custom VBA function

    You want Application.Caller.Row

    Can't imagine any situation where this would be a good approach though?
    Remember what the dormouse said
    Feed your head

  3. #3
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Trying to mimic row() in custom VBA function

    Do you mean like this?

    Please Login or Register  to view this content.
    If you are happy with my response please click the * in the lower left of my post.

  4. #4
    Registered User
    Join Date
    09-08-2015
    Location
    Chicago, Illinois
    MS-Off Ver
    2010
    Posts
    2

    Re: Trying to mimic row() in custom VBA function

    Quote Originally Posted by romperstomper View Post
    You want Application.Caller.Row

    Can't imagine any situation where this would be a good approach though?
    This did the trick. Thank you!

+ 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. [SOLVED] SOLVED! Mimic VBA IF using =IF
    By Amediar in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-06-2014, 03:14 PM
  2. Finding a way to mimic Alt + = for the SUM function
    By Excel_vba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-27-2013, 12:59 PM
  3. How to mimic a column..?
    By Auhsey in forum Excel General
    Replies: 9
    Last Post: 09-04-2012, 03:32 PM
  4. Function to mimic SQL-style lookup
    By imbubbling in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-13-2007, 08:16 PM
  5. Mimic another worksheet
    By edwardpestian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2006, 02:29 AM
  6. [SOLVED] Mimic keystrokes?
    By Targus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2006, 01:15 PM
  7. [SOLVED] Mimic Print Preview?
    By JK in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 12:55 AM
  8. mimic goalseek
    By Monique in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-25-2005, 03:05 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