Solved

Help with excel 2010

Posted on 2011-09-05
3
276 Views
Last Modified: 2012-05-12
Hello

Can someone please assist me in writing a macro for the attached?

Basically all I need is for the macro to search column Q ‘client’ find all matching numbers eg ‘57337’ filter on that and then in column P ‘order’ it needs to find the lowest and highest number and copy both of those rows and past into a new sheet.

Can this be done?

Any assistance is appreciated!

test.xlsx
0
Comment
Question by:vegas86
[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 39

Accepted Solution

by:
nutsch earned 500 total points
ID: 36486487
This code should do it. Uncomment the two lines to get the title row copied too.

Thomas
Sub Macro2()
Dim cl As Range, lMax As Long, lMin As Long, lLoop As Long
Dim shtOrg As Worksheet, shtDest As Worksheet

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.DisplayAlerts = False

Set shtOrg = ActiveSheet

shtOrg.Cells(1, 1).AutoFilter
shtOrg.Cells(1, 1).CurrentRegion.AutoFilter Field:=17, Criteria1:="57337"

lMax = Application.WorksheetFunction.Subtotal(4, shtOrg.Columns(16))
lMin = Application.WorksheetFunction.Subtotal(5, shtOrg.Columns(16))

Set shtDest = Sheets.Add
lLoop = 1

'to get title row, uncomment lines below
'shtOrg.Rows(1).Copy shtDest.Rows(1)
'lLoop = 2

For Each cl In shtOrg.Cells(1, 1).CurrentRegion.Columns(16).SpecialCells(xlCellTypeVisible)
    If cl = lMax Or cl = lMin Then
        cl.EntireRow.Copy shtDest.Rows(lLoop)
        lLoop = lLoop + 1
    End If
Next

shtOrg.Cells(1, 1).AutoFilter

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Application.DisplayAlerts = True

End Sub

Open in new window

0
 

Author Closing Comment

by:vegas86
ID: 36486497
Works perfectly!!

Thank you!
0
 
LVL 39

Expert Comment

by:nutsch
ID: 36486521
Glad to help. Thanks for the grade.

Thomas
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Suggested Solutions

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
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…

738 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