Click here to Skip to main content
15,892,161 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Excel Programmers out there:

I have got a workbook with two sheets.

sheet1 gets data from sheet2 e.g

a2 in sheet1 will get data from shee2!a2

But sheet2 is filtered. What I want is that when I select a record randomly in sheet2,a2 in sheet1 should be populated automatically. Whatever a record selected in sheet2,a2 in sheet1 should be filled/copied,when selecting another record the previous record should be cleared and bring in the newly selected one.

Please help with the code.

Thanks
Posted
Updated 28-Dec-10 3:10am
v2
Comments
MrBatra 28-Dec-10 9:44am    
If I understand it clearly, this is what you need -->
Sheet1 should be populated always with new value; as soon as something is selected in sheet2.

1 solution

You need to hook the worksheet's SelectionChange event.

Go into the VB editor (Alt+F11).

Double-Click the Sheet2 Object.

In the left drop-down box, select Worksheet. That should automatically add a SelectionChange event.

If not, use the right drop-down to select SelectionChange.

Then, in the code block, just write:
VB
Sheet1.Range("A2").Value = Target.Value
 
Share this answer
 
Comments
Manfred Rudolf Bihy 28-Dec-10 13:29pm    
Good call!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900