PC Review


Reply
Thread Tools Rate Thread

Create New Sheets from Filtered List - help on macro

 
 
Tea
Guest
Posts: n/a
 
      9th Mar 2008
Hi all,



I would appreciate help with VBA.

I am trying to edit VBA macro for creating new sheets from filtered list,
and i am somewhat stuck.

I managed to edit macro so that it filters column 4, but i dont know how to
write few lines of code so that macro does the following:



a.. On created sheets, at the bottom of the last column with data, to
summarize the data. Name of that coloumn will always be 'Grand Total'
b.. On 'UniqueList' sheet, VBA should name coloumn B:'Grand Total', and
paste appropriate 'Grand Total' value
c.. On sheet 'UniqueList', in the cell at the bottom of coloumn B, grand
total for created sheets should be summarized.


Thx in advance,

Goran





Sub PagesByDescription()

Dim rRange As Range, rCell As Range

Dim wSheet As Worksheet

Dim wSheetStart As Worksheet

Dim strText As String



Set wSheetStart = ActiveSheet

wSheetStart.AutoFilterMode = False

'Set a range variable to the correct item column

Set rRange = Range("d1", Range("d65536").End(xlUp))



'Delete any sheet called "UniqueList"

'Turn off run time errors & delete alert

On Error Resume Next

Application.DisplayAlerts = False

Worksheets("UniqueList").Delete



'Add a sheet called "UniqueList"

Worksheets.Add().Name = "UniqueList"



'Filter the Set range so only a unique list is created

With Worksheets("UniqueList")

rRange.AdvancedFilter xlFilterCopy, , _

Worksheets("UniqueList").Range("A1"), True



'Set a range variable to the unique list, less the heading.

Set rRange = .Range("a2", .Range("a65536").End(xlUp))

End With



On Error Resume Next

With wSheetStart

For Each rCell In rRange

strText = rCell

.Range("a1").AutoFilter 4, strText

Worksheets(strText).Delete

'Add a sheet named as content of rCell

Worksheets.Add().Name = strText

'Copy the visible filtered range _

(default of Copy Method) and leave hidden rows

.UsedRange.Copy Destination:=ActiveSheet.Range("A1")

ActiveSheet.Cells.Columns.AutoFit

Next rCell

End With



With wSheetStart

.AutoFilterMode = False

.Activate

End With



On Error GoTo 0

Application.DisplayAlerts = True

End Sub





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create sheet with records for each rep in filtered list Aline Microsoft Excel Programming 3 16th Dec 2008 07:29 PM
Create New Sheets from Filtered List Koo30lau Microsoft Excel Programming 3 13th Apr 2008 08:17 PM
Create a list filtered by keyword =?Utf-8?B?TWlrZUw=?= Microsoft Access Queries 1 14th Dec 2005 08:04 PM
Create New Sheets from Filtered List using Template =?Utf-8?B?U29DYWxDeWJlcmdhbA==?= Microsoft Excel Programming 0 1st Nov 2005 07:20 PM
Re: How to create a dropdown list that contains filtered values Norman Jones Microsoft Excel Misc 0 20th Jul 2004 05:55 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:10 AM.