Macro to fill in dates from one sheet to another finding the account line?

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,

I have two sheets.

1 "Raw Data" and holds a list of sales
2 "Sales" and is my official Sales list.
I need to update one column in Sales with the new data from "Raw Data"

so heres what I need.
In "Raw Data" column A has a Ref Number. (that's rows 2 to last row)
In "Sales" the same Ref Numbers are stored in Column A but not the same rows.
so I need a macro that can get the Ref Numbers from "Raw Data" and find them in "Sales" then add the value in Column J of "Raw Data" to the row it found in "Sales" column Z.

I hope that make sense?

Basically I'm trying to move data from Raw Data to Sales data by finding the Row in sales that should hold the info.

please help if you can

Thanks

Tony
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try this

Code:
Sub Fill_Sales()
  Dim sh1 As Worksheet, sh2 As Worksheet, i As Long, f As Range
  Set sh1 = Sheets("Sales")
  Set sh2 = Sheets("Raw Data")
  For i = 2 To sh2.Range("A" & Rows.Count).End(xlUp).Row
    Set f = sh1.Range("A:A").Find(sh2.Cells(i, "A"), , xlValues, xlWhole)
    If Not f Is Nothing Then
      sh1.Cells(f.Row, "Z").Value = sh1.Cells(f.Row, "Z").Value + sh2.Cells(i, "J")
    End If
  Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,219
Members
452,619
Latest member
Shiv1198

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