Hi kaprmg,
As you're new to VBa, some explanation.
You need to write code which will run whenever any change is made to one of your cells. The way to do this is by creating a special routine which is triggered by Excel whenever any cell on the sheet changes. Within this routine you can check which cell(s) have changed and if your chosen cells are involved then you run whatever you want to.
The special routine is called
Worksheet_Change and must go in the code module belonging to the sheet. In the VB Editor, probably on the left hand side, is the Project Explorer (if you can't see it, press Ctrl+R to bring it up). Within the project explorer you will see an entry for your workbook and under it, a heading: "Microsoft Excel Objects"; under this you will see a list of all the Sheets in your workbook. Double click on the sheet you want to change (Sheet1). This will bring the sheet's code module (probably blank) into focus in the main editor window.
At the top of the main window are two dropdowns. From the one on the left select
Worksheet - this will generate some code in the window which you do not want at the moment so you can delete it. Then from the dropdown on the right select
Change - this will generate a procedure which will run every time anything on he worksheet changes, and looks like this:
Code:
[blue]Private Sub Worksheet_Change(ByVal Target As Range)
End Sub[/blue]
Inside this procedure paste the following code:
Code:
[blue]Dim Source As Range
Dim SingleCell As Range
For Each SingleCell In Intersect(Target, Range("A7:A41"))
ThisWorkbook.Names("product").RefersToRange.Find(SingleCell.Value).Offset(0, 1).Resize(1, 6).Copy
Application.EnableEvents = False
ActiveSheet.Paste SingleCell.Offset(0, 1)
Application.EnableEvents = True
Next
Application.CutCopyMode = False[/blue]
That's it! What this code does is check each of your cells (range a7:a41) which has changed and looks up the value on sheet2 - it then just copies the six columns to the right including formats.
Enjoy,
Tony
--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at [url=http://www.vbaexpress.