Solved

Automate Excel Task

Posted on 2012-03-25
3
297 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

This collection of functions covers all the normal rounding methods of just about any numeric value.
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 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

10 Experts available now in Live!

Get 1:1 Help Now