Solved

Fill in missing rows using Date column

Posted on 2016-09-02
5
41 Views
Last Modified: 2016-09-04
I am trying to fill in missing data based on a Date column from one sheet to another.

In Sourcebook1.xlsx, there are rows of data with a date in column E
In DestBook1.xlsx, there are rows of data with a date also in column E.
What I want is to copy the group of rows from sourcebook1 to Destbook1 for any dates that do not exist in Destbook1.

For example, in DestBook1, there are no rows with a date of 7/30/16. In Sourcebook1, there are 762 rows with a date of 7/30 so I want to copy those 762 rows to DestBook1 after the last current row, then resort the sheet so the data is sorted by date.

DestBook1 also has no rows with a date of 4/9/2016 so again, copy the rows from SourceBook1 to DestBook1.

Lastly I need a message box that says either:
"No rows were copied" (meaning there were no missing dates in DestBook1)
Or "Missing Dates 4/9/16, 7/30/16 were copied".

Hope I explained this clearly and thanks for your help in advance.

swjtx99
DestBook1.xlsx
SourceBook1.xlsx
0
Comment
Question by:swjtx99
  • 3
  • 2
5 Comments
 
LVL 29

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41782926
Please find the attached with the code and with a button called "Copy Data From Source Workbook".
Please click the button to run the code. The code will prompt you to select the source workbook and copy data from the source workbook for the dates which are missing in the macro workbook.
DestBook1.xlsm
0
 

Author Closing Comment

by:swjtx99
ID: 41783299
Hi Subodh,

This is great!

Can you advise how I can copy more columns? The example only had 5 columns but the production version has 15 (up to column O)

Thank you very much for your help!

swjtx99
0
 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41783379
You're welcome.

In that case you only need to replace the following lines of code...
This Line
sws.Range("A2:E" & slr).SpecialCells(xlCellTypeVisible).Copy ws.Range("A" & Rows.Count).End(3)(2)

Open in new window

With This
sws.Range("A2:O" & slr).SpecialCells(xlCellTypeVisible).Copy ws.Range("A" & Rows.Count).End(3)(2)

Open in new window


AND

This Line
ws.Range("A2:E" & lr).Sort key1:=ws.Range("E2"), order1:=xlAscending, Header:=xlGuess

Open in new window

With This
ws.Range("A2:O" & lr).Sort key1:=ws.Range("E2"), order1:=xlAscending, Header:=xlGuess

Open in new window

0
 

Author Comment

by:swjtx99
ID: 41784107
That worked. Thanks again,
0
 
LVL 29

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41784209
You're welcome.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article briefly covers methods of calculating the NPV and IRR variants in Excel as well as the limitations in calculating and interpreting IRR results. Paraphrasing Richard Shockley, author of my favourite finance reference tex…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question