Add address based on text from drop down menu.

Geek Girl 007

Board Regular
Joined
Mar 12, 2022
Messages
172
Office Version
  1. 2021
Platform
  1. Windows
Sheeela's Accounts.xlsx
AB
4Invoice information
5
6Invoice Number:
7To:
8Address:
9
10
11
12Function:
13Date:
14Duration:
15Cost:
INVOICE
Cells with Data Validation
CellAllowCriteria
B7List=TABLES!$A$2:$A$5


If I select 'The Grapes' from cell B7 I want the address 12 Dow Street, SW12 3TH to appear in B8 however If I select 'Shaftesbury Club' I want the address 1 Peter Close, SE11 3GH to appear, and so forth.

Can this be done??
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
In order to do what you want, you would need a list (perhaps on a different sheet) that would include the drop down values in column A and the corresponding addresses in column B. Do you have this data anywhere in your workbook?
 
Upvote 0
In order to do what you want, you would need a list (perhaps on a different sheet) that would include the drop down values in column A and the corresponding addresses in column B. Do you have this data anywhere in your workbook?
Yes, I do now, how do I show you?
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your INVOICE sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make a selection in the drop down in B7.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("B7")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim customer As Range
    Set customer = Sheets("MAIN").Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
    If Not customer Is Nothing Then
        Range("B8") = customer.Offset(, 1)
    End If
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your INVOICE sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Make a selection in the drop down in B7.
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    If Intersect(Target, Range("B7")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim customer As Range
    Set customer = Sheets("MAIN").Range("A:A").Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
    If Not customer Is Nothing Then
        Range("B8") = customer.Offset(, 1)
    End If
    Application.ScreenUpdating = True
End Sub
Is there any way it can be done without a macro?
It's just an accounts program for my mum, I'm trying to keep it simple.... thanks
 
Upvote 0
If we put a formula in B8, it would return the correct address based on the selection in B7. However, this would work only the first time a selection is made in B7 because the address returned by the formula in B8 would overwrite the formula thereby deleting it. The macro is the simplest way to do what you want. It is entered as I described only once. Your mum doesn't even need to know it is there. All she has to do is enter the necessary data in the Main sheet. She can modify it by adding, deleting or changing the data without affecting the macro. After inserting the macro, save the file as a macro-enabled file. Macros of course, must be enabled in Excel.
 
Upvote 0
If we put a formula in B8, it would return the correct address based on the selection in B7. However, this would work only the first time a selection is made in B7 because the address returned by the formula in B8 would overwrite the formula thereby deleting it. The macro is the simplest way to do what you want. It is entered as I described only once. Your mum doesn't even need to know it is there. All she has to do is enter the necessary data in the Main sheet. She can modify it by adding, deleting or changing the data without affecting the macro. After inserting the macro, save the file as a macro-enabled file. Macros of course, must be enabled in Excel.
 
Upvote 0
How about
Fluff.xlsm
AB
1
2
3
4Invoice information
5
6Invoice Number:
7To:Shaftesbury Club
8Address:128 Lavender Hill, London, SW11 5RB
9
10
11
12Function:
13Date:
14Duration:
15Cost:
Sheet5
Cell Formulas
RangeFormula
B8B8=VLOOKUP(B7,Main!A2:B4,2,0)
Cells with Data Validation
CellAllowCriteria
B7List=Main!$A$2:$A$4
 
Upvote 0
Solution

Forum statistics

Threads
1,225,738
Messages
6,186,734
Members
453,369
Latest member
juliewar

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