+ Reply to Thread
Results 1 to 9 of 9

How to find row number and include in formula

  1. #1
    Registered User
    Join Date
    11-15-2022
    Location
    Washington State, USA
    MS-Off Ver
    360 ProPlus
    Posts
    31

    How to find row number and include in formula

    I have a table of data in a workbook. Each row has a formula that points to that rows row number. Currently the formula is: =--ISNUMBER(IFERROR(SEARCH($L$3,A28,1),""))

    After inserting a new record using a UserForm, the record is inserted OK but the row number is now off by one on all the following records. In the formula above, the offending reference s the ,A28,
    I would like to have, in this example, reference the row the formula is actually in.

    Thank you.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,502

    Re: How to find row number and include in formula

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    11-15-2022
    Location
    Washington State, USA
    MS-Off Ver
    360 ProPlus
    Posts
    31

    Re: How to find row number and include in formula

    Here is a copy of the file.
    Attached Files Attached Files

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,502

    Re: How to find row number and include in formula

    So, you're looking for the contents of cell $L$3 in the current row of column A. So, on row 3, you are looking for $L$3 in cell A3.

    Where do you insert the row? And what do you want to happen? A28 should stay the same?

  5. #5
    Registered User
    Join Date
    11-15-2022
    Location
    Washington State, USA
    MS-Off Ver
    360 ProPlus
    Posts
    31

    Re: How to find row number and include in formula

    If you click the button at the bottom of sheet one, use the form to add a new record using data that does not match any of the dummy data. After the record is inserted, check the formula in column H.
    The row reference for that record and the one below it should not match the row the data is in.

    Cell L3 in Sheet 2 contains the record text of what was selected in the combo box on Sheet 1. Then, the formula being references in column gets that value and finds all matches of that selection in column A in the database.

    Hope that makes sense. It also happens if you insert a row directly in the database by inserting a new row.
    Last edited by TeacherWart; 01-31-2023 at 03:58 PM.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,502

    Re: How to find row number and include in formula

    After inserting a new record using a UserForm, the record is inserted OK but the row number is now off by one on all the following records.
    I don't think I was able to reproduce the problem.

    That said, if it DOES happen, I suggest you re-establish the formulae in columns I:K. Do that by calling the subroutine below.

    Please Login or Register  to view this content.

    Please note that this has been tested independently. It has NOT been tested when called from elsewhere. As stated, it should be called AFTER a row has been inserted to maintain the integrity of the formulae. Unfortunately, because the application changes the Excel environment, I am not prepared to test it IRL. If the (original) code fails/crashes for any reason, it could leave a lot of sorting out to do ... and I'm not going to take that risk.

  7. #7
    Registered User
    Join Date
    11-15-2022
    Location
    Washington State, USA
    MS-Off Ver
    360 ProPlus
    Posts
    31

    Re: How to find row number and include in formula

    Thank you. I will be trying your example tomorrow and will get back to you.

  8. #8
    Registered User
    Join Date
    11-15-2022
    Location
    Washington State, USA
    MS-Off Ver
    360 ProPlus
    Posts
    31

    Re: How to find row number and include in formula

    Your code works perfectly. Thank you so much.

  9. #9
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,502

    Re: How to find row number and include in formula

    You're welcome. Thanks for the rep.

+ 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. How to include number in cell as part of formula
    By lakk30 in forum Excel General
    Replies: 4
    Last Post: 09-19-2022, 08:49 PM
  2. [SOLVED] Formula required to find the nth nearest number to a selected number
    By josephteh in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-05-2019, 05:49 PM
  3. Replies: 1
    Last Post: 04-10-2017, 03:33 PM
  4. Replies: 1
    Last Post: 10-07-2016, 02:16 PM
  5. Replies: 17
    Last Post: 08-26-2014, 01:05 PM
  6. [SOLVED] How to create a formula/format for a long number to include a period and not round
    By Rita Bush in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 12-13-2013, 01:13 PM
  7. Replies: 3
    Last Post: 07-07-2006, 09:10 PM

Tags for this Thread

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