AutoFill From One Sheet to Another

montyfern

Board Regular
Joined
Oct 12, 2017
Messages
65
Greetings,

My client wants to do this: My goal is to use the directory in the second tab to auto fill the row based on the last name entered. For example, if I type in Smith, the row will autofill with the first name, location, branch, and supervisor. I would then have to manually fill in the device type, decal, etc.

I've looked at other posts and forums and so far am empty handed. Is this an Index, Match, VBA, or? I tried to write an Index and Match to no avail:
=INDEX(XYZ DIrectory!A$5:A$500,MATCH($A5,All XYZ Property!$A$4:$A$500,0))

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Last NameFirst NameBranchSupervisorOffice Phone NumberCell/iPhone #Email AddressOffice/Workstation Location
OhioAkronSPEBSmith, Joan703.525.6666 ak.oh@aol.comFL/1000
ArlingtonVirginiaSPEBSmith, Joan 703-979-8885arling.va@aol.comOff-Site

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col></colgroup>
Greetings,

My client wants to do this: "goal is to use the directory in the second tab to auto fill the row based on the last name entered. For example, if I type in Smith, the row will autofill with the first name, location, branch, and supervisor. I would then have to manually fill in the device type, decal, etc."

I've looked at other posts and forums and so far am empty handed. Is this an Index, Match, VBA, or? I tried to write an Index and Match to no avail:
=INDEX(XYZ DIrectory!A$5:A$500,MATCH($A5,All XYZ Property!$A$4:$A$500,0))

Thanks!

Here you go, MUMPS, and apologies. I had to "dummify" the data. Thanks very much!
SHEET1
Last Name

First Name

Location

Branch

upervisor
Device TypeDecal #ManufacturerModelPurchase DateSurplused?NotesReplacement Estimate
AkronOhioFL/100OHOSmith, JoanPrinter00011100HPQ5401A11/15/2005No
AkronOhioFL/100SPEBSchwetz, TaraMonitor01729185Dell2408WFP5/29/2008No
AkronOhioFL/102SPEBSchwetz, TaraLaptop01984244HPZBook159/24/2015No
SHEET2
Akron


Ohio
FL/103SPEBSchwetz, TaraComputer CPU02042515HPZ2305/25/2016No

Last NameFirst NameBranchSupervisorOffice Phone NumberCell/iPhone #Email AddressOffice/Workstation Location
OhioAkronSPEBSmith, Joan703.525.6666 ak.oh@aol.comFL/1000
ArlingtonVirginiaSPEBSmith, Joan 703-979-8885arling.va@aol.comOff-Site

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col></colgroup>

<tbody>
</tbody><colgroup><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup>
 
Upvote 0
My apologies. I know you have gone through a lot of trouble posting your data but the way the data is displayed is confusing. You say: "if I type in Smith" but I don't see "Smith" in the Last Name column. I see names of cities or states. Also, what happens if there are more than one "Smith"? Could I ask you to upload a copy of your file to a free site such as www.box.com. or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do referring to specific cells and worksheets. For example, where do you type in the last name. If the workbook contains confidential information, you could replace it with generic data. Working on your actual file will make it easier to understand how your data is organised and test any possible solution.
 
Upvote 0
My apologies. I know you have gone through a lot of trouble posting your data but the way the data is displayed is confusing. You say: "if I type in Smith" but I don't see "Smith" in the Last Name column. I see names of cities or states. Also, what happens if there are more than one "Smith"? Could I ask you to upload a copy of your file to a free site such as www.box.com. or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Include a detailed explanation of what you would like to do referring to specific cells and worksheets. For example, where do you type in the last name. If the workbook contains confidential information, you could replace it with generic data. Working on your actual file will make it easier to understand how your data is organised and test any possible solution.

https://www.dropbox.com/s/8gonvxw8glb77j0/MOCK_AUTOFILL_EXAMPLE.xlsx?dl=0

No my apologies, mumps. We had a gov't shutdown & I had to leave tres vite. My only detailed explanation is auto-filling data. There is no specific cell reference. All I need please is when I enter a last name in Cell A1 or A20 or whatever, then an auto-fill function knows to add the First Name, Location, Branch, and Supervisor. I would have to manually add device type, decal, etc. Does this make sense? Is it a macro?
Thanks MUCH!
 
Upvote 0
mumps, my names are (last name) OHIO (first name) AKRON. If I start typing Ohio then auto-fill knows to add Akron, my Location, branch & supervisor. Hope that clarifies.
 
Upvote 0
Hopefully, I have understood correctly. Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your Sheet1 and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a last name in column A and exit the cell. I noticed that on Sheet2 you had the last and first name columns reversed. Make sure that the last names in Sheet2 are in column A.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim foundName As Range
    Set foundName = Sheets("Sheet2").Range("A:A").Find(Target, LookIn:=xlValues, lookat:=xlWhole)
    If Not foundName Is Nothing Then
        Target.Offset(0, 1) = foundName.Offset(0, 1)
        Target.Offset(0, 2) = foundName.Offset(0, 7)
        Target.Offset(0, 3) = foundName.Offset(0, 2)
        Target.Offset(0, 4) = foundName.Offset(0, 3)
    End If
    Application.ScreenUpdating = False
End Sub
 
Upvote 0
Hopefully, I have understood correctly. Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your Sheet1 and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Enter a last name in column A and exit the cell. I noticed that on Sheet2 you had the last and first name columns reversed. Make sure that the last names in Sheet2 are in column A.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim foundName As Range
    Set foundName = Sheets("Sheet2").Range("A:A").Find(Target, LookIn:=xlValues, lookat:=xlWhole)
    If Not foundName Is Nothing Then
        Target.Offset(0, 1) = foundName.Offset(0, 1)
        Target.Offset(0, 2) = foundName.Offset(0, 7)
        Target.Offset(0, 3) = foundName.Offset(0, 2)
        Target.Offset(0, 4) = foundName.Offset(0, 3)
    End If
    Application.ScreenUpdating = False
End Sub

Dear Mumps, PERFECTO! I had to rename the sheet to her desired name so I edited the macro. When I insert a line the macro errors out as it doesn't understand what cell it's referencing but as long as it's in column A I can just hit End and it works brilliantly.

MANY MANY thanks. I don't like VBA but teach Excel ;) Headed to Power Pivot and Power Query....
 
Upvote 0
You are very welcome. :) Try this version. It should eliminate the error.
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    Application.ScreenUpdating = False
    Dim foundName As Range
    Set foundName = Sheets("Sheet2").Range("A:A").Find(Target, LookIn:=xlValues, lookat:=xlWhole)
    If Not foundName Is Nothing Then
        On Error GoTo errHandler
        Target.Offset(0, 1) = foundName.Offset(0, 1)
        Target.Offset(0, 2) = foundName.Offset(0, 7)
        Target.Offset(0, 3) = foundName.Offset(0, 2)
        Target.Offset(0, 4) = foundName.Offset(0, 3)
    End If
errHandler:
    Application.ScreenUpdating = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,792
Messages
6,121,612
Members
449,039
Latest member
Mbone Mathonsi

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