Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro 2 Extract Data 2 Paste in New Wksht


undefined

Each morning a spreadsheet is sent to various regional managers - The
person who generates this just creates another row - It is sorted by
date - and separated by an empty row.

So I may have two rows with column "A" as a date, "B" as a problem, "C"
as something else, "D" as a region...etc. Then a blank or empty row,
then the yesterday's section..there may have been 3 or 4 rows of
data...and so on...

So...what I have been doing manually is to search for the empty rows
and delete all but the last one...

Then I do an AutoFilter...

Then I sort Column "D" - Region - one region at a time ( I am
responsible for 15 or so ) once it's sorted for a specific region - I
select the entire series of rows pertaining to that region and copy and
paste to a separate worksheet in the same workbook for that region.

I wasn't sure where to start...I was trying to create a macro...one at
a time and then maybe I could put them altogether...and create one
complete macro...first to eliminate those empty rows..all but the last
one...

I would really appreciate any assistance anyone could offer...


--
JP2R


------------------------------------------------------------------------
JP2R's Profile: http://www.excelforum.com/member.php...o&userid=23582
View this thread: http://www.excelforum.com/showthread...hreadid=385125

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 44
Default Macro 2 Extract Data 2 Paste in New Wksht

Try this...

Sub SplitRegions()
'''Splits data on active sheet into separate sheets based on data in column D
' Only values in column D matching the list in columnA of Sheet "List" will
be coppied
Const cNumSourceColumns As Integer = 4

Dim rngRegionList As Range, rngR As Range, rngList As Range
Dim wsSource As Worksheet, wsDest As Worksheet
Dim lLastRow As Long

Set wsSource = ActiveSheet

'get last row in source sheet
lLastRow = wsSource.Cells(wsSource.Rows.Count, 1).End(xlUp).Row
'sort the data by date, then problem
wsSource.Range("A1").Resize(lLastRow, cNumSourceColumns).Sort
key1:=wsSource.Range("A1"), key2:=wsSource.Range("B1"), header:=xlYes '
change 4 to required number of columns
'blank rows now sorted to bottom, so get new last row
lLastRow = wsSource.Cells(wsSource.Rows.Count, 1).End(xlUp).Row
Set rngList = wsSource.Range("A1").Resize(lLastRow, cNumSourceColumns)

'find list of Regions to extract and loop through
Set rngRegionList =
ThisWorkbook.Sheets("List").Range("A1").Resize(Thi sWorkbook.Sheets("List").Cells(ThisWorkbook.Sheets ("List").Rows.Count, 1).End(xlUp).Row, 1)
For Each rngR In rngRegionList
rngList.AutoFilter field:=4, Criteria1:=rngR.Formula
Set wsDest = ActiveWorkbook.Worksheets.Add
wsDest.Name = rngR.Formula
rngList.Copy Destination:=wsDest.Range("A1")
Next rngR
wsSource.AutoFilterMode = False
End Sub

Cheers,
Dave

"JP2R" wrote:


undefined

Each morning a spreadsheet is sent to various regional managers - The
person who generates this just creates another row - It is sorted by
date - and separated by an empty row.

So I may have two rows with column "A" as a date, "B" as a problem, "C"
as something else, "D" as a region...etc. Then a blank or empty row,
then the yesterday's section..there may have been 3 or 4 rows of
data...and so on...

So...what I have been doing manually is to search for the empty rows
and delete all but the last one...

Then I do an AutoFilter...

Then I sort Column "D" - Region - one region at a time ( I am
responsible for 15 or so ) once it's sorted for a specific region - I
select the entire series of rows pertaining to that region and copy and
paste to a separate worksheet in the same workbook for that region.

I wasn't sure where to start...I was trying to create a macro...one at
a time and then maybe I could put them altogether...and create one
complete macro...first to eliminate those empty rows..all but the last
one...

I would really appreciate any assistance anyone could offer...


--
JP2R


------------------------------------------------------------------------
JP2R's Profile: http://www.excelforum.com/member.php...o&userid=23582
View this thread: http://www.excelforum.com/showthread...hreadid=385125


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro 2 Extract Data 2 Paste in New Wksht


I really appreciate this...wow!


--
JP2R


------------------------------------------------------------------------
JP2R's Profile: http://www.excelforum.com/member.php...o&userid=23582
View this thread: http://www.excelforum.com/showthread...hreadid=385125

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
1st 2 rows of wksht show up @ top of each page of the wksht Remote Paralegal Excel Discussion (Misc queries) 2 October 6th 08 07:59 PM
Macro to Copy/Paste Data into one wksht, skipp one row before past Shoney Excel Discussion (Misc queries) 1 February 22nd 08 01:28 AM
Need macro to remove duplicate rows in a wksht with same order# G2 in AUS Excel Discussion (Misc queries) 2 December 16th 05 05:44 PM
macro to extract info and paste to a new sheet Brad K. Excel Programming 1 March 11th 05 10:29 PM
add macro to wksht i-Zapp Excel Programming 1 February 4th 04 06:07 PM


All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"