+ Reply to Thread
Results 1 to 6 of 6

Autofill and function not working Need HELP!

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-15-2013
    Location
    United States
    MS-Off Ver
    Excel 2016
    Posts
    214

    Autofill and function not working Need HELP!

    I have the following function code
    =IF(MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000))),INDEX(Sheet2!M:M,MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000)))),"")
    listed in cell V2 on sheet 1. After that is placed i then run the following macro for an autofill.
    Sub Autofill()
        Range("V2").Autofill Range("V2:V" & Range("A" & Rows.Count).End(xlUp).Row)
    End Sub
    The problem I'm running into is that the pasting of the function and the autofill are not working correctly and I do not know why. The corresponding cells that are suppose to increase with the autofill are not increasing. It should be A2 for row 2 and A3 for row 3 and so on. Any suggestions are greatly appreciated.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Autofill and function not working Need HELP!

    Maybe:

    Sub trevor2524zzzz()
    Range("V2:V" & Range("A" & Rows.count).End(3)(1).Row).Formula = "=YOUR FORMULA GOES HERE"
    End Sub

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Autofill and function not working Need HELP!

    Hi, trevor2524,

    just combine the codes instead of writing the formula first and then using Autofill:
    Sub Autofill()
        Range("V2:V" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=IF(MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000))),INDEX(Sheet2!M:M,MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000)))),"""")"
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Forum Contributor
    Join Date
    06-15-2013
    Location
    United States
    MS-Off Ver
    Excel 2016
    Posts
    214

    Re: Autofill and function not working Need HELP!

    Quote Originally Posted by HaHoBe View Post
    Hi, trevor2524,

    just combine the codes instead of writing the formula first and then using Autofill:
    Sub Autofill()
        Range("V2:V" & Range("A" & Rows.Count).End(xlUp).Row).Formula = "=IF(MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000))),INDEX(Sheet2!M:M,MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000)))),"""")"
    End Sub
    Ciao,
    Holger
    Thanks that one works the only thing it is needing now is how do i add the crtl+shift+enter to that macro so that each cell after the function it does that.

  5. #5
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Autofill and function not working Need HELP!

    Hi, trevor2524,

    no need to quote full posts in every answer.

    You didnīt indicate the formula to be an array formula in any way. Normally I would suggest
    Sub Autofill_2()
        Range("V2:V" & Range("A" & Rows.Count).End(xlUp).Row).FormulaArray = "=IF(MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000))),INDEX(Sheet2!M:M,MAX(IF(ISNUMBER(SEARCH($A2,Sheet2!$A$2:$E$5000)),ROW(Sheet2!$A$2:$E$5000)))),"""")"
    End Sub
    which would create one big array formula which could only be altered throughout (no iidividual modification for a row is possible).

    Ciao,
    Holger

  6. #6
    Forum Contributor
    Join Date
    06-15-2013
    Location
    United States
    MS-Off Ver
    Excel 2016
    Posts
    214

    Re: Autofill and function not working Need HELP!

    I think i see what your saying. Ok i'll try and figure out another way to go about the whole process and see if there is someway I can manipulate it. I'll post if I have any more questions. Thanks again for your help. It helped out alot.

+ 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] autofill not working
    By stubyh in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-23-2013, 12:32 PM
  2. Autofill not working
    By rdhull in forum Excel General
    Replies: 4
    Last Post: 10-28-2011, 04:05 PM
  3. Autofill down is not working???
    By rmurray in forum Excel General
    Replies: 1
    Last Post: 05-20-2009, 02:50 PM
  4. lastRow & Autofill not working
    By dvent in forum Excel General
    Replies: 0
    Last Post: 04-08-2008, 06:19 AM
  5. [SOLVED] AutoFill isnt working?
    By M.L in forum Excel General
    Replies: 7
    Last Post: 06-16-2005, 04:05 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