Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Automate Excel Task

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

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…
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

828 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