+ Reply to Thread
Results 1 to 9 of 9

when i put an Array formula through VBA, it does not work as epected

  1. #1
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    when i put an Array formula through VBA, it does not work as epected

    Afternoon Happy Campers,

    I have a sheet, containing two tabs.

    tab 1 - In cell A1, i type a Post Code.

    tab 2 - In cell A1 down i have a list of post codes
    In Cell B1 down i have a list of addresses
    (The range of A:B in tab 2 has been named as DATA)

    So, i have a formula that will do it that i can leave in the cells:
    Please Login or Register  to view this content.
    Which works great when it is entered as an array formula in set cells (B1:B10) but the refresh time for it is slow when the data in cell A1 changes, so i played with the idea of using VBA, and only calling the code via command button.
    After some research i came up with the following:
    Please Login or Register  to view this content.
    But when the above runs, its almost like it executes it too fast and just pastes values without the formula actually refreshing and showing the correct results.

    Would anyoen be kind enough to have a go at setting it right for me?

    Kind regards
    galvinpaddy

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

    Re: when i put an Array formula through VBA, it does not work as epected

    I think you need to use .formulaarray for vba otherwise it won't be an array formula. So:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: when i put an Array formula through VBA, it does not work as epected

    Hi, firstly, thanks for your response!
    However, i get a similar result.

    When i run the macro, it doesnt populate properly for me.
    In Tab1 Cell A1, if i type in the post code XXD12 0ZZA
    the the array formula should show me 3 different results in column B, but it shows me the same one.

    I cant attache the sheet as its over 9kb and i also cant reduce the size as i dont know how to seperate the personal.xls bits (have lots of macros saved there.

    But essentially, i have the following in on tab 2.

    XX11 2AL Tersus Group
    XX8 1AU MOBILE FUN LIMITED
    XX8 1AU Mobile Fun Limited
    XX8 1AU Pyramid Display Materials Ltd
    XXD12 0ZZA Styrene Packaging | Insulation
    XXD12 0ZZA RP & P Management
    XXD12 0ZZA RICHARDSON BUSINESS EQUIPMENT
    XXD7 1HZZ Belgravium (D/A)
    XXD7 1HZZ MAINDEC COMPUTER SOLUTIONS
    XXD7 1HZZ COMODO CA LTD
    XXD7 1HZZ Maindec Computer Solutions
    XXD7 1HZZ UK Resource Centre for Women in S E T
    XXD7 1HZZ O H S Ltd
    XXD7 1HZZ Vantage Trading Ltd

    Regards

  4. #4
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: when i put an Array formula through VBA, it does not work as epected

    you cannot assign the formulaarray to all the cells in one pass-that's a totally different formula; perhaps
    Please Login or Register  to view this content.
    Josie

    if at first you don't succeed try doing it the way your wife told you to

  5. #5
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: when i put an Array formula through VBA, it does not work as epected

    Hi JosephP,

    When i run your code, i get a compile error, Syntax error.
    It highlights the following line in red
    Please Login or Register  to view this content.

  6. #6
    Forum Expert millz's Avatar
    Join Date
    08-14-2013
    Location
    Singapore
    MS-Off Ver
    Excel, Access 2016
    Posts
    1,694

    Re: when i put an Array formula through VBA, it does not work as epected

    Quote Originally Posted by galvinpaddy View Post
    But when the above runs, its almost like it executes it too fast and just pastes values without the formula actually refreshing and showing the correct results.
    If it's because it didn't calculate before it's pasted, maybe try adding a ActiveSheet.Calculate before the copy?

  7. #7
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: when i put an Array formula through VBA, it does not work as epected

    I apologize-typo
    Please Login or Register  to view this content.
    oughta be
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    11-02-2011
    Location
    Rugby, England
    MS-Off Ver
    Office 365
    Posts
    846

    Re: when i put an Array formula through VBA, it does not work as epected

    Great stuff, thanks alot to all who offered support, and thank-you to JosephP/Yudlugar for the solution, REP all round :D

    **edit - cant add rep for Joseph, apparently i need to spread the rep before adding more for you :D

  9. #9
    Forum Guru JosephP's Avatar
    Join Date
    03-27-2012
    Location
    Ut
    MS-Off Ver
    2003/10
    Posts
    7,328

    Re: when i put an Array formula through VBA, it does not work as epected

    don't worry-thank you is sufficient ;-)

+ 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. Ammended Array Formula will not work
    By rikapple in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-08-2013, 06:53 AM
  2. How does this array formula work?
    By Motox in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-10-2012, 09:46 AM
  3. This array formula won't work?
    By edwardpestian in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-08-2006, 02:13 AM
  4. Help. Don't know why this array formula does not work.
    By fbarbie in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-02-2005, 11:54 AM
  5. Will an Array Formula work here?
    By Rob Gould in forum Excel General
    Replies: 2
    Last Post: 02-01-2005, 10:06 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