URGENT! Need a quick way to auto-fill some cells

%3CLINGO-SUB%20id%3D%22lingo-sub-2391438%22%20slang%3D%22en-US%22%3EURGENT!%20Need%20a%20quick%20way%20to%20auto-fill%20some%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2391438%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20I%20enter%20the%20same%20product%20name%2C%20I%20need%20it%20to%20auto-fill%20some%20cells%20belonging%20to%20that%20product.%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%20yesterday%20I%20entered%20a%20product%20%22Kero%20Domates%20Fidesi%22%20as%20you%20can%20see%20in%20yellow.%20The%20numbers%20belonging%20to%20that%20product%20are%20the%20same%20like%20its%20buying%20price%20and%20selling%20price.%20So%20when%20I%20enter%20the%20same%20product%20today%20I%20want%20the%20program%20to%20fill%20automatically%20the%20buying%20price%20and%20selling%20price.%20I%20don't%20want%20to%20copy%20paste%20the%20cells%20all%20day.%20Can%20someone%20help%20me%20please%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Ekran%20Al%C4%B1nt%C4%B1s%C4%B1.PNG%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F284284i68AB729CA809632B%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22Ekran%20Al%C4%B1nt%C4%B1s%C4%B1.PNG%22%20alt%3D%22Ekran%20Al%C4%B1nt%C4%B1s%C4%B1.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2391438%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2391593%22%20slang%3D%22en-US%22%3ERe%3A%20URGENT!%20Need%20a%20quick%20way%20to%20auto-fill%20some%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2391593%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1064782%22%20target%3D%22_blank%22%3E%40gamzeoz93%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhich%20column%20contains%20the%20product%20names%3F%3C%2FP%3E%0A%3CP%3EWhich%20column%20contains%20the%20buying%20price%3F%3C%2FP%3E%0A%3CP%3EWhich%20column%20contains%20the%20selling%20price%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2391668%22%20slang%3D%22en-US%22%3ERe%3A%20URGENT!%20Need%20a%20quick%20way%20to%20auto-fill%20some%20cells%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2391668%22%20slang%3D%22en-US%22%3E%3CP%3EI%20tagged%20them%20in%20black%20in%20the%20first%20bar%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

When I enter the same product name, I need it to auto-fill some cells belonging to that product. 

For example yesterday I entered a product "Kero Domates Fidesi" as you can see in yellow. The numbers belonging to that product are the same like its buying price and selling price. So when I enter the same product today I want the program to fill automatically the buying price and selling price. I don't want to copy paste the cells all day. Can someone help me please? 

 

 

Ekran Alıntısı.PNG

5 Replies

@gamzeoz93 

Which column contains the product names?

Which column contains the buying price?

Which column contains the selling price?

I tagged them in black in the first bar @Hans Vogelaar 

I sent you a message because I can't load a picture here.

@gamzeoz93 

You haven't specified which columns (B, C, ...), so I'll assume that the product price is in column B.

Right-click the sheet tab.

Select 'view Code' from the context menu.

Copy the following code into the worksheet module:

Private Sub Worksheet_Change(ByVal Target As Range)
    Const ProductCol = "B"
    Dim cel As Range
    Dim cel2 As Range
    If Not Intersect(Columns(ProductCol).EntireColumn, Target) Is Nothing Then
        Application.ScreenUpdating = False
        Application.EnableEvents = False
        For Each cel In Intersect(Columns(ProductCol).EntireColumn, Target)
            If cel.Value <> "" Then
                Set cel2 = Columns(ProductCol).Find(What:=cel.Value, After:=cel, LookAt:=xlWhole)
                If cel2.Address <> cel.Address Then
                    cel.Offset(0, 4).Value = cel2.Offset(0, 4).Value
                    cel.Offset(0, 5).Value = cel2.Offset(0, 5).Value
                End If
            End If
        Next cel
        Application.EnableEvents = True
        Application.ScreenUpdating = True
    End If
End Sub

Switch back to Excel.

Save the workbook as a macro-enabled workbook (*.xlsm).

Make sure that you allow macros when you open the workbook.

 

Thank you very much I will try