Macro to index/look up cell and place data onto another sheet

ardykav

Board Regular
Joined
Oct 18, 2015
Messages
172
Office Version
  1. 365
Platform
  1. Windows
Hi All,

I have two sheets, Weekly Sales and Yearly Sales. Column A on Weekly Sales has the 7 days of the week running from cells A10:A16, On the yearly sales the dates run from cell A3:A368.

The idea is that the weekly sheet is populated and then a macro copies all data from the weekly sheet (B10:E16) and puts it into the yearly sales sheet beside the relevant date in column B.

All help greatly appreciated,
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
This is just a suggestion but coarse code.

Code:
Sub ardykav()
Dim wsW As Worksheet, wsY As Worksheet
Dim LastR As Long

Set wsW = Sheets("Weekly Sales")
Set wsY = Sheets("Yearly Sales")

LastR = wsY.Cells(Rows.Count, 2).End(xlUp).Row

With wsW
    wsY.Range(wsY.Cells(LastR + 1, 2), wsY.Cells(LastR + 7, 5)).Value = .Range("B10:E16").Value
    .Range("B10:E16").ClearContents
End With

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,391
Messages
6,124,678
Members
449,179
Latest member
fcarfagna

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