Solved

Macro to build error report in Excel from data in the same workbook

Posted on 2016-11-04
3
27 Views
Last Modified: 2016-11-04
I want a separate worksheet in Excel to build an error report from another worksheet in the same workbook.  The data would be a list of employee positions such as full time, part time, temps, seasonal etc...and ONLY full time positions should have insurance costs listed in a particular field.  I want the report to search the data and if it finds insurance expense in that field for any other position than a full time position, copy the entire row of information and add it to the error list.   The problem I am having is having the report build the list so that there are no empty rows on the list.  I don't know a simple way with a formula to do this and assume I need a macro to build it so that as it finds the data, it puts it on the next available line on the report.   Once I have a macro to do it, I'd like to set up a button and assign the macro to it so I can run it when I want.  I have attached a very simple sample.
EE-Example-Error-Report.xlsx
0
Comment
Question by:Johnette Connelley
3 Comments
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41874245
Hi,

pls try
Sub macro()
Sheets("Data File").Activate
For Each c In Range(Range("A3"), Range("A" & Rows.Count).End(xlUp))
    If c <> "FULL TIME" Then
        c.Resize(, 2).Copy Destination:=Sheets("Error Report").Range("A" & Rows.Count).End(xlUp).Offset(1)
    End If
Next
End Sub

Open in new window

Regards
1
 

Author Closing Comment

by:Johnette Connelley
ID: 41874296
Worked beautifully!  I am new to Macros and this is excellent. Thanks!
0
 
LVL 18

Expert Comment

by:Roy_Cox
ID: 41874309
Duplicating data to another sheet is not the best way to work with data. I would simply use Conditional Formatting to highlight the cells, in the newer versions of Excel you can always filter by colour and print the list if required.
EE-Example-Error-Report.xlsx
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

785 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