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
184 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
  • 4
4 Comments
 
LVL 43

Accepted Solution

by:
Saqib Husain, Syed earned 500 total points
Comment Utility
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
Comment Utility
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
Comment Utility
This macro should be placed in the code pane for the sheet in question
0
 
LVL 43

Expert Comment

by:Saqib Husain, Syed
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

743 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now