lookup in worksheet_change event

  • Thread starter Thread starter rumkus
  • Start date Start date
R

rumkus

Hi All

Worksheet1 contains below columns ( price list )
Company season price

Worksheet 2 contains sales
Company season amount price cost

Company and season are picked from another list.
What I want is ( if possible ) when I put amount price is picked from
sheet1 and multiply with amount for cost.

I know this too much but how can I put such formulas in
worksheet_change event.
Can you direct me to such postings.

Thank you in advance
 
open event code for SHEET 2 and try this code

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng, ref As Range
Application.EnableEvents = False
Set rng = Worksheets("sheet1").UsedRange
Set ref = Target.Offset
If Target.Column <> 3 Then Exit Sub
Target.Offset(0, 1) = WorksheetFunction.VLookup(Target.Offset(0, -2), rng,
3, False)

Target.Offset(0, 2) = Target * Target.Offset(0, 1)
Application.EnableEvents = True
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top