Solved

Automate Excel Task

Posted on 2012-03-25
3
301 Views
Last Modified: 2012-05-30
Part C:

This is a follow-on from Part B:

http://www.experts-exchange.com/Microsoft/Applications/Q_27647644.html#a37762768


A macro is needed which will look at Col A of tab “Raw Data – copy” and where it finds a “C_Num” which has an alpha character it will:
-       remove that row and write it to a new tab called “CS only”.  
-      Insert row totals and cross-totals
-      Adjust the totals of tab “Raw Data – copy”

Thanks.
0
Comment
Question by:RishiSingh05
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Norie earned 500 total points
ID: 37762928
This can be done with filters.
Option Explicit

Sub FilterDataOnCS()
Dim ws As Worksheet
Dim wsData As Worksheet
Dim wsCSAlpha As Worksheet
Dim wsCSNum As Worksheet
Dim rngData As Range
Dim rngCrit As Range
Dim LastRow As Long

    Set wsData = Worksheets("Raw Data")

    LastRow = wsData.Range("A" & Rows.Count).End(xlUp).Row

    Set rngData = wsData.Range("A1:H" & LastRow)

    Set rngCrit = wsData.Range("P1:P2")

    rngCrit.Cells(1) = "*"

    rngCrit.Cells(2) = "=ISTEXT(A2)"

    Set wsCSAlpha = Worksheets.Add

    wsCSAlpha.Name = "CS Alpha"

    rngData.AdvancedFilter xlFilterCopy, rngCrit, wsCSAlpha.Range("A1")

    Set wsCSNum = Worksheets.Add

    wsCSNum.Name = "CS Number"

    rngCrit.Cells(2) = "=ISNUMBER(A2)"

    rngData.AdvancedFilter xlFilterCopy, rngCrit, wsCSNum.Range("A1")

    rngCrit.ClearContents

    ' add totals to worksheets
    For Each ws In Worksheets(Array("CS Number", "CS Number"))
        Call AddTotals(ws)
    Next ws

End Sub

Open in new window

0
 

Author Comment

by:RishiSingh05
ID: 37762976
The worksheet this macro applies to is "Raw Data - copy" not "Raw Data".  So I guess if I make the change in:  Set wsData = Worksheets("Raw Data")
I should be ok.
0
 
LVL 33

Expert Comment

by:Norie
ID: 37763181
Isn't 'Raw Data - copy' just a copy of 'Raw Data'?

Or is it a copy that's had the JobCost has been removed?

Why not just run the code on the 'Raw Data' worksheet?

Perhaps if you could explain the overall aim that might make things clearer.

Do you want to split out the data from the 'Raw Data' worksheet based on certain criteria?

PS If you do make the change then the code should still work.
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
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…
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now