+ Reply to Thread
Results 1 to 10 of 10

VBA - Index double match and insert values in range

  1. #1
    Registered User
    Join Date
    11-26-2011
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    11

    Question VBA - Index double match and insert values in range

    Hi

    To clear things up : im a vba newbie

    I have done a bit searching online but i havent found any help online.

    I have a workbook (A) where i import new data from
    another workbook (B) on a daily basis.
    The reason for this is because the data in B is updating itself from another system and i am not allowed to edit anything in B.

    My basic idea is that i want to import the sheet named Book_1 from B into A so i can add comments and import this sheet on a daily basis so i always have the updated data from workbook B.

    The data from book_1 populates range A to K, so i use range L for commenting

    I have solved most of the problems, but i want to improve the workbook by moving some formulas into VBA to speed things up.

    This is my question : Can this formula be inserted into VBA :

    =IF(Ordre!A4="";"";IFERROR(INDEX(KommentarBackup!$C$2:$C$15000;MATCH(Ordre!A4&Ordre!B4;KommentarBackup!$A$2:$A$15000&KommentarBackup!$B$2:$B$15000;0));""))

    The value must be inserted into Sheet(Ordre) range L4 and down as long as range A4 and down contains data

    Currently this array formula is populated in another range (X4 to X15000) and i have a macro to do a copy / paste values into L4 and down. This forces me to set the workbook into manual calculation and slows things down alot

    Any help i appreciated
    Last edited by Biinge; 12-02-2011 at 02:45 PM.

  2. #2
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA - Index double match and insert values in range

    Biinge,

    Something like this?
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    11-26-2011
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA - Index double match and insert values in range

    Quote Originally Posted by tigeravatar View Post
    Biinge,

    Something like this?
    Please Login or Register  to view this content.
    Thanks!

    I get a runtime error though

    "Run-time error 1004: Unable to set the FormulaArray property of the Range Class"

    Any idea why this error pops up?

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA - Index double match and insert values in range

    I'd have to see a sample workbook

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

    Re: VBA - Index double match and insert values in range

    Quote Originally Posted by tigeravatar View Post
    I'd have to see a sample workbook
    Here you go

    This is just a sample of the data with the array formula in sheet 2.

    As explained i use the array formula to ensure that the backup comments in sheet 2 is placed in the right cell in sheet 1.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    11-26-2011
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA - Index double match and insert values in range

    Quote Originally Posted by Biinge View Post
    Here you go

    This is just a sample of the data with the array formula in sheet 2.

    As explained i use the array formula to ensure that the backup comments in sheet 2 is placed in the right cell in sheet 1.
    Sorry forgot to say that the reason i do this is to import the backup in sheet (kommentarbackup) , range C into sheet(Ordre) range L. I have a macro that does that

  7. #7
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA - Index double match and insert values in range

    Biinge,

    Give this a try:
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    11-26-2011
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA - Index double match and insert values in range

    Quote Originally Posted by tigeravatar View Post
    Biinge,

    Give this a try:
    Please Login or Register  to view this content.
    Brilliant, thanks! :D

    All i want it to do now is to insert the value instead of the formula

  9. #9
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA - Index double match and insert values in range

    Updated code:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-26-2011
    Location
    Norway
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: VBA - Index double match and insert values in range

    That code works perfect!
    Just the way i wanted it to (And the workbook is 10 times faster and went from 10 MB to 200kb :D

    Thanks

+ 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