Forum Discussion

jjelliott's avatar
jjelliott
Copper Contributor
Apr 27, 2022
Solved

Copying data that changes location on a worksheet

Hello Excel folks.   I am hoping for some VBA help.  I am needing to copy data, daily, from a report generated as a worksheet.  That data is always in teh same location relative to the data label (...
  • mathetes's avatar
    mathetes
    Apr 28, 2022

    jjelliott 

    Here's a formula for you to try. 

     

    =INDEX([Source.xlsx]Sheet1!$M$1:$M$100,XMATCH("Fruit: Apples",[Source.xlsx]Sheet1!$B$1:$B$100,0)+1)

     

    I've made it work in the attached very rough example files.

    Basic ideas:

    • the XMATCH portion determines the row in column B in which the text "Fruit: Apples" appears
    • the INDEX function takes that row, adds 1, and finds the value in the resulting row in column M

    You'd have to do some things to adapt it to your situation. 

    • change the references, both to the actual source files real name, and to the range of rows possible (I use 100 as the max)
    • once the value has been retrieved, change it from a formula to a value; this might involve writing a VBA routine, but whether that's needed could depend on the volume of transactions

Resources