Copy cell value based on multiple criteria

cepinac

New Member
Joined
Jul 18, 2022
Messages
9
Office Version
  1. 2019
Platform
  1. MacOS
Hi everyone, I've been trying to figure out this by myself but it's out of my reach.

Quick description:
Sheet "Sales" contains 3 columns:
Customer Name | Product | Qty
Workbook contains another 10 sheets with different customer names (same as "Sales" Customer Name).

Sheet "Customer XYZ" contains multiple colums but key one is Product (with matching name as sheet "Sales").

I would like to copy Qty of matching Customer and Product then paste it in an appropriately named sheet.

i.e.
Sales sheet:
Customer XYZ | Oranges | 10
copy 10 and paste it to a Specified colum (i.e. N) and a row containing Oranges in sheet Customer XYZ.

Thank you :)

1658153617552.png
1658153645032.png
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
A bit confusing, you say sheet "customerxyz" but your sheet names are the product names.
 
Upvote 0
If you upload a sample to workbook to a shared drive, then supplied a link, it would be a great help.
 
Upvote 0
If you upload a sample to workbook to a shared drive, then supplied a link, it would be a great help.
sure, here you go. btw data can be pasted into any column i can adjust accordingly afterwards

thx for helping

 
Upvote 0
try this.

VBA Code:
Sub Send_It_Man()
    Dim sh As Worksheet, ws As Worksheet
    Dim rng As Range, c As Range, fRng As Range

    Set sh = Sheets("Sell_Out")
    With sh
        Set rng = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
    End With

    For Each c In rng.Cells
        Set fRng = Sheets(c.Value).Range("A:A").Find(what:=c.Offset(, 1), lookat:=xlWhole)
        If Not fRng Is Nothing Then
            fRng.Offset(, 1) = c.Offset(, 2)

        End If
    Next c
    
End Sub
 
Upvote 0
Solution
try this.

VBA Code:
Sub Send_It_Man()
    Dim sh As Worksheet, ws As Worksheet
    Dim rng As Range, c As Range, fRng As Range

    Set sh = Sheets("Sell_Out")
    With sh
        Set rng = .Range("A2:A" & .Cells(.Rows.Count, "A").End(xlUp).Row)
    End With

    For Each c In rng.Cells
        Set fRng = Sheets(c.Value).Range("A:A").Find(what:=c.Offset(, 1), lookat:=xlWhole)
        If Not fRng Is Nothing Then
            fRng.Offset(, 1) = c.Offset(, 2)

        End If
    Next c
   
End Sub
thank you it works fast :)
how would you go about changing paste column?
 
Upvote 0
There is not paste, you are making one cell equal another cell.
VBA Code:
fRng.Offset(, 1)
For this example it's column B

VBA Code:
fRng.Offset(, 2)
would be column C
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,019
Members
448,938
Latest member
Aaliya13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top