active cell

charly1

Board Regular
Joined
Jul 18, 2023
Messages
87
Office Version
  1. 365
Platform
  1. Windows
hi all

I am relatively new to excel, so my question may indeed be a simple one.

I would like to write a "xlookup formula" in which the "lookup value" is constantly updated to refer to the "activecell". Is this possible without using vba and without having to double click the active cell to update the reference in the cell containing the xlookup formula?

Any help would be greatly appreciated!
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
No it's not possible without VBA.
 
Upvote 0
Ok.

So would it be to much to ask for someone out there to post the necessary vba code that I need.

I would like to insert the xlookup code into cell "A1" of sheet1, the lookup value would always be the active cell. The lookup array should refer to a Table column on that same sheet 1 and the return array should be 2 side by side columns in a separate table in sheet 2.

Thanks ever so much for any help in advance.
 
Upvote 0
sorry, if may just add one final point to my q. I would like the vba to only run the xlookup when the active cell happens to be a cell in a specific column of an excel table.
 
Upvote 0
It is hard to tailor VBA to work on your specific situation without detailed information.
Please show us some sample data and your expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
It is hard to tailor VBA to work on your specific situation without detailed information.
Please show us some sample data and your expected results.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
Hi

thanks for answering.

I have copied the sample data below. The xlookup appears in cell A1. I would like to have that formula for that cell written in vba, where lookup value is not cell P190 as it currently stands but to rather to always refer to the active cell - provided the active cell is in the table column P. All other data in the above function is to remain the same.

Please note though, the lookup array and return array refer to columns of a table that appear in a separate spreadsheet of the same workbook.

Thanks again in advance. Any help would be appreciated immensely.

NewCat.xlsm
ABCDEFGHIJKLMNOP
1אחרונים1870ה' תרל1921ה' תרפא51ראשונים1050
2
3עמודה1עמודמדף1Column1Column2ספרחלקיםנושא כללי: בנושאיםנושא פרטי: בנושאיםנושא: בספריםנושא כללי: בנושאים [שני]נושא פרטי: בנושאים [שני]נושא: בספרים [שני]תוכןמחבר
4--ספר ראומהד3הלכות שחיטות ובדיקות לקדמוני איטליא0הלכהיו"ד: א'-קכ"ב [מאכלות אסורות], פסקי ראשונים וגדולי האחרוניםיו"ד-----
5ח,ט7-  טור - מהד' המאור23הלכהספרי טושו"עספרי טושו"ע-----
6ח4-  טור - מהד' שירת דבורה [בינוני]23הלכהספרי טושו"עספרי טושו"ע-----
7מועדיםמועדים-  טור - מהד' שירת דבורה [גדול]21הלכהספרי טושו"עספרי טושו"ע-----
8ח, ט2-  טור - מהד' שירת דבורה [קטן]23הלכהספרי טושו"עספרי טושו"ע-----
9ח, ט3-  טור ושו"ע - שירת דבורה [קטן]38הלכהספרי טושו"עספרי טושו"ע-----
10כט8-  מאורות הראשונים1הלכהפסקי ראשונים וגדולי האחרוניםפסקי הראשונים וגדולי האחרונים-----
11--שבלי הלקט - מהדו"יד3מנהג טוב0הלכהפסקי ראשונים וגדולי האחרוניםפסקי הראשונים וגדולי האחרונים-----
12--משנה ברורה - מהד' דרשוי2,3ספר המפתח [למ"ב] - דרשו0הלכהאורח חייםאורח חיים-----
13כט8-  ספר קושיות1הלכהפסקי ראשונים וגדולי האחרוניםפסקי הראשונים וגדולי האחרונים-----
14ט,י7-  שולחן ערוך - מהד' פרידדמן34הלכהספרי טושו"עספרי טושו"ע-----
15ט5-  שולחן ערוך - מהדו"י10הלכהספרי טושו"עספרי טושו"ע-----
16ח5-  שולחן ערוך - צורת הדף10הלכהספרי טושו"עספרי טושו"ע-----
מפתח
Cell Formulas
RangeFormula
A1:F1A1=XLOOKUP(P190,ArtistName,Table2[[עמודה2]:[עמודה7]])
O1:P1O1=XLOOKUP(P2756,ArtistName,Table2[[עמודה2]:[DOB CAL]])
E4:E16E4=IF([@1]="-","",XLOOKUP([@1],[ספר],[עמוד]))
F4:F16F4=IF([@1]="-","",XLOOKUP([@1],[ספר],[מדף]))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
ArtistName=מחברים!$A$7:$A$1872A1:F1, O1:P1
ר__אחא__אחאי__משבחא=מחברים!$A$8:$A$1872A1:F1, O1:P1
Cells with Data Validation
CellAllowCriteria
P4:P16List=ArtistName
 
Upvote 0
Go to sheet where you want to apply this to (the sheet where you want to update the formula in cell A1), then right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this VBA code in the VB Editor window that pops-up:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'   Check to see if selected cell is in column P under row 3
    If Target.Column = 16 And Target.Row > 3 Then
'       Update formula in cell A1 with address of selected cell
        Range("A1").Formula "=XLOOKUP(" & Target.Address & ",ArtistName,Table2[[עמודה2]:[עמודה7]])"
    End If
    
End Sub
Now, as you pick any cell value in column P beneath row 3, it will populate your lookup formula in cell A1 with the address of that cell.
 
Upvote 0
Go to sheet where you want to apply this to (the sheet where you want to update the formula in cell A1), then right-click on the sheet tab name at the bottom of the screen, select "View Code", and paste this VBA code in the VB Editor window that pops-up:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'   Check to see if selected cell is in column P under row 3
    If Target.Column = 16 And Target.Row > 3 Then
'       Update formula in cell A1 with address of selected cell
        Range("A1").Formula "=XLOOKUP(" & Target.Address & ",ArtistName,Table2[[עמודה2]:[עמודה7]])"
    End If
   
End Sub
Now, as you pick any cell value in column P beneath row 3, it will populate your lookup formula in cell A1 with the address of that cell.
Thanks so much for your time, however it didn't work. I've attached a screenshot showing what happened when I entered it.
Screenshot 2023-07-18 194820.png
 
Upvote 0
By the way, for some reason it didn't show up on the screenshot picture attached above, however the word ".formula" in your code washighlighted in blue, when the error message popped up.

Thanks again, for the effort.
 
Upvote 0
Sorry, there is a typo in that code. When I was trying to copy the special characters of your alphabet, I lost an equal sign. It should be:
Rich (BB code):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

'   Check to see if selected cell is in column P under row 3
    If Target.Column = 16 And Target.Row > 3 Then
'       Update formula in cell A1 with address of selected cell
        Range("A1").Formula = "=XLOOKUP(" & Target.Address & ",ArtistName,Table2[[עמודה2]:[עמודה7]])"
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,280
Members
449,220
Latest member
Excel Master

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