Solved

what can be the macro for copy the content of data from one spreadsheet to another when the user is making change event?

Posted on 2011-03-17
4
190 Views
Last Modified: 2012-05-11
what can be the macro for copy the content of data from one spreadsheet to another when the user is making change in a specefic column?

for example:
when user is typing value to filed A1 a macro will run and will look (search) for this value in second spreadsheet on lets says column B and if it find this value it will take the value that in column C on second speadsheet and will copy it to the first spreadsheet to filed B1

please advice
thanks
Nir
0
Comment
Question by:gvilbis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
4 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
ID: 35159175
Does this have to be a macro? This can more conveniently be done using the Vlookup function.

Enter this formula in B1

=IF(ISNA(VLOOKUP(A1,Sheet2!B:C,2,0)),"",VLOOKUP(A1,Sheet2!B:C,2,0))
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 500 total points
ID: 35159263
If it must be a macro then you can use

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("A1").Address Then
Range("B1").ClearContents
On Error Resume Next
Range("B1") = WorksheetFunction.VLookup(Target, Sheet2.Range("B:C"), 2, 0)
End If
End Sub
0
 
LVL 43

Assisted Solution

by:Saqib Husain, Syed
Saqib Husain, Syed earned 500 total points
ID: 35159271
This macro should be placed in the code pane for the sheet in question
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
ID: 35314862
Hi, thankyou for the points and the grade.

I would like to emphasise the importance of judicial selection of accepted answers. The spirit of this site is to build a knowledge base which could help other users benefit from. Selection of so many responses would simply confuse someone who is trying to look for solutions to his or her problem. Furthermore, if you would select the answer you used it would give me more feedback on the type of answers the end user could be looking for. Furthermore the acceptance of my third comment was simply meaningless as it is not a solution but just a pointer to how to use the solution.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

628 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question