VB SCRIPT HELP - Delete Data from an excel spreadsheet based on certain cell value

laurensims41

New Member
Joined
Feb 4, 2016
Messages
22
I Have to pull a report every morning that is very lengthy and has everyone in the organization's data on it. I would like to be able to delete everyone else's data that are not the 10 people that report up to me


The Spreadsheet goes from Cells A to AK

COLUMN AM has the data of the people I would like to keep the information on. Any Help would be appreciated.
Lauren Sims
Jocy Sims
Kendal Perkins
Breanne Lewis
James Sims
Laura Bedwell
Betsy Bedwell
Ryan Enochs
Chris Bowne
Shannon Erlenbush
Danielle Futrell
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Assuming row 1 A-AK is headers and AM1 has the exact same header as the column you look in for the names
and your people are in AM2 and down


You can extract your people to another sheet using Advanced Filter
Something along the lines of this
Code:
Sub ExtractMyPeople()


Dim src As Worksheet, dest As Worksheet
Dim lr As Long, critRng As Range


Set src = Sheets("Sheet1")
Set dest = Sheets("Sheet2")


With src
    lr = .Columns("A:AK").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    Set critRng = .Range("AM1", .Cells(Rows.Count, "AM").End(xlUp))
    .Range("A1:AK" & lr).AdvancedFilter xlFilterCopy, critRng, dest.Cells(1)
End With


End Sub
 
Upvote 0
It didn't pull any data passed Column AM, but it did put data into another sheet. I really appreciate your help on this.

Your above Assumptions are correct.

The Column AM is titled Buyer

I am not seeing where I would designate the names of the individuals I am trying to pull out of the report?
 
Upvote 0
It didn't pull any data passed Column AM
Should it ?
From post 1
The Spreadsheet goes from Cells A to AK
made me wonder about column AM :confused:
I can't see your spreadsheet, can only guess at what you're working with from how you describe it.
Perhaps you want to elaborate a little more ?
 
Upvote 0
I am sorry I really mis-typed the original ask.

The Spreadsheet is from A to AZ.
Header's in ROW 1.



I would like all data associated with the following names moved to a separate sheet or everyone deleted: These Names are in Column AN w/ a Header BUYER;
Lauren Sims
Jocy Sims
Kendal Perkins
Breanne Lewis
James Sims
Laura Bedwell
Betsy Bedwell
Ryan Enochs
Chris Bowne
Shannon Erlenbush
Danielle Futrell
 
Upvote 0
Do you want to keep those names, or delete them?
 
Upvote 0
How about this ?
You add a new sheet and name it People
In A1 put the same header as your AN (Buyer) column has.
In A2 and down, list the people whose data you want to extract to another sheet.
This range on the People sheet, (A1:A12) according to the list of 11 names you've supplied, will be used as the criteria range to advance filter the src sheet.

Code:
Sub ExtractMyPeople()

    Dim src As Worksheet, dest As Worksheet
    Dim lr As Long, critRng As Range

Set src = Sheets("Sheet1")      'change sheet name if necessary
Set dest = Sheets("Sheet2")     'change sheet name if necessary
Set critRng = Sheets("People").Range("A1", Sheets("People").Range("A" & Rows.Count).End(xlUp))

With src
    lr = .Columns("A:AZ").Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    .Range("A1:AZ" & lr).AdvancedFilter xlFilterCopy, critRng, dest.Cells(1)
End With

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,906
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top