SEARCHING ANOTHER WORKBOOK FOR CURRENT ACTIVE TEXT OFFSET AND RETURNING TEXT FROM 3 CELLS OFFSET FROM FOUND TEXT

BAKELOVEMORE

New Member
Joined
Apr 2, 2024
Messages
13
Office Version
  1. 365
Platform
  1. Windows
I have 2 workbooks. I use one workbook to track issues that I have input on the other workbook. i.e. on the current workbook, I need to search the second workbook for a value offset by -3 from the current workbooks activecell. I need to take that text value found on the second workbook and insert the text found in the cells offset by 2 and 3 and 4. i.e. The text value offset by -3 of the active cell is Banana. Find Banana in column 3 and insert the concat text from columns 5 , 6, 7.

VBA Code:
=IF(E24="TEXT",CONCAT('[OTHER SHEET.xlsm]Sheet1'!$E$2, "     ", '[OTHER SHEET.xlsm]Sheet1'!$F$2, "     ",'[OTHER SHEET.xlsm]Sheet1'!$G$2))

This works but I would have to use IFS and nest 66 different variables. I have tried using named cells as ranges. And activecell.offset, etc. I would also have to drag this formula down 32 cells. I really would rather have a function that I can just click when I need it because not all lines in my main workbook will need this.
 
Try assign this macro to a shape. Select a cell and push the button.

VBA Code:
Sub InsertFormula()
    Dim activeRow As Long
    Dim formula As String

    ' Get the active row number
    activeRow = ActiveCell.Row

    ' Construct the formula with a dynamic reference to cell E & activeRow
    formula = "=TEXTJOIN("" "",TRUE,FILTER('[OTHER SHEET.xlsm]Sheet1'!$E$2:$G$100,'[OTHER SHEET.xlsm]Sheet1'!$C$2:$C$100 = E" & activeRow & "))"

    ' Insert the formula into column H of the active cell's row
    ActiveSheet.Cells(activeRow, "H").Formula = formula
End Sub
 
Upvote 0
Solution

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
I recorded a macro pasting this into a cell but of course it recorded the actual cell. I need to change the Range().Select to use the current cell.
Try assign this macro to a shape. Select a cell and push the button.

VBA Code:
Sub InsertFormula()
    Dim activeRow As Long
    Dim formula As String

    ' Get the active row number
    activeRow = ActiveCell.Row

    ' Construct the formula with a dynamic reference to cell E & activeRow
    formula = "=TEXTJOIN("" "",TRUE,FILTER('[OTHER SHEET.xlsm]Sheet1'!$E$2:$G$100,'[OTHER SHEET.xlsm]Sheet1'!$C$2:$C$100 = E" & activeRow & "))"

    ' Insert the formula into column H of the active cell's row
    ActiveSheet.Cells(activeRow, "H").Formula = formula
End Sub
Worked Great! Thanks so much.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,179
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top