[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Automate Excel Task

Posted on 2012-03-25
3
Medium Priority
?
311 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
[X]
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
  • 2
3 Comments
 
LVL 35

Accepted Solution

by:
Norie earned 2000 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 35

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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

649 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