• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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

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
  • 4
3 Solutions
Saqib Husain, SyedEngineerCommented:
Does this have to be a macro? This can more conveniently be done using the Vlookup function.

Enter this formula in B1

Saqib Husain, SyedEngineerCommented:
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
On Error Resume Next
Range("B1") = WorksheetFunction.VLookup(Target, Sheet2.Range("B:C"), 2, 0)
End If
End Sub
Saqib Husain, SyedEngineerCommented:
This macro should be placed in the code pane for the sheet in question
Saqib Husain, SyedEngineerCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now