VBA: Copy/Paste cells from Old Data Sheet into new Data Sheet based on criteria

Lres81715

Board Regular
Joined
Aug 26, 2015
Messages
147
Hello everyone,

I have a massive project that has sheets that need to be updated at least once a week. I have an existing VBA code that pulls certain columns from the Database and pastes them into a new sheet. "CalNew"
The worksheet from the previous week "CalOld" has information that is manually entered all throughout the week and it needs to be carried over to "CalNew" (Note: This sheet will eventually be renamed CalOld by the end of the week to continue the process the following week) . I currently use a MATCH/INDEX INDIRECT formula to match the data from both sheets. However, I want to automate this process as my workflow just tripled.

I've attached a sample of the worksheet in question but I'll be using this same formula for nearly 30 new sheets with a similar setup but different criteria and identifiers for each project.

https://app.box.com/s/zu3oow4j6ii11igfrtn5f4tw1augxdn7

I don't need anything fancy. The simpler the better as I'm only beginner level VBA.

Long story short, I want a VBA code that does a Match/Index function but created to be edited in a simple way. If you can add 'comments and notes along the way, I would be forever grateful! =) thanks all.
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Additional Notes that might be important:
As the week progresses, the status of some orders will drop off the report (IE: Future CalNew) as it moves into the next stage. Also: New orders will then appear on CalNew in various positions unique to a particular filter sort. They will then need to be manually updated and most likely need to be copied over as CalOld into CalNew. Thus the cycle repeats.
Column B on both CalNew and CalOld are the unique identifiers that I use to match the data. L M N O P are the columns that are manually entered and updated each week that need to be carried over. This report normally has between 30-100 rows of revolving data at any given data depending on the time of the month. Hope that helps in clarifying any questions you might have
 
Upvote 0
Try this. Copy to standard code module 1
Code:
Sub copyStuff()
Dim sh1 As Worksheet, sh2 As Worksheet, c As Range, fn As Range 'declare variables
Set sh1 = Sheets("CalNew") 'initialize variables
Set sh2 = Sheets("CalOld")
    With sh1
        For Each c In .Range("B2", .Cells(Rows.Count, 2).End(xlUp)) 'initiate loop to walk down col B of CalNew
            Set fn = sh2.Range("B:B").Find(c.Value, , xlValues, xlWhole) 'look for matched value, column B
                If Not fn Is Nothing Then 
                    fn.Offset(0, 11).Resize(1, 5).Copy c.Offset(0, 11) 'If match found, copy the five columns to other sheet.
                End If
        Next
    End With
End Sub
 
Last edited:
Upvote 0
Change this line to:
Code:
fn.Offset(0, 10).Resize(1, 5).Copy c.Offset(0, 10)
 
Upvote 0

Forum statistics

Threads
1,216,051
Messages
6,128,503
Members
449,455
Latest member
jesski

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