Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Grup and subtotal in VBA

For filter and delete I used this code

------------------------------------------------------------------

Dim rng As Range

Columns("I:I").Select
ActiveWorkbook.Names.Add name:="ListNames",
RefersToR1C1:="=Raport!C9"


Application.Goto Reference:="ListNames" 'Range for names

Selection.AutoFilter
Selection.AutoFilter Field:=1, _
Criteria1:="<1"

Set rng = ActiveSheet.AutoFilter.Range
Set rng = rng.Offset(1, 0).Resize(rng.Rows.Count - 1)
Set rng = rng.Columns(1).SpecialCells(xlVisible).EntireRow
rng.Delete
ActiveSheet.AutoFilterMode = False


Dim wsNew As Worksheet

Set wsNew = Worksheets.Add(After:=Worksheets(Worksheets.Count) )

wsNew.name = "Supergrupa"

Sheets("Raport").Select
ActiveSheet.UsedRange.Select
Selection.Copy
Sheets("Supergrupa").Select
ActiveSheet.Paste
Range("B:B,C:C,I:I,J:J,K:K").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
Range("A1").Select

Range("A1").Value = "Magazin"
Range("B1").Value = "Val1"
Range("C1").Value = "Val2"
Range("D1").Value = "Val3"
Range("E1").Value = "Supergr_id"
Range("F1").Value = "Supergr_den"

wsNew.Columns.AutoFit

Sheets("Raport").Select
Range("B:B,C:C,I:I").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft

------------------------------------------------------------------

Because I have 16000 rows and I use this subtotal twice it takes 2
minutes to complete.

I think that there are other ways to do this job faster, but 2 minutes
is not such a long time to wait.

Bye!

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
Subtotal To Include Item Description On Subtotal Line Tickfarmer Excel Discussion (Misc queries) 2 February 23rd 10 07:56 PM
sort macro, subtotal and add lines after subtotal David Excel Discussion (Misc queries) 1 August 29th 09 10:56 AM
pasting to subtotal lines without replacing hidden -non-subtotal l harleydiva67 Excel Discussion (Misc queries) 1 October 12th 06 06:02 PM
Subtotal of Subtotal displays Grand Total in wrong row Thomas Born Excel Worksheet Functions 5 January 6th 05 01:46 PM
Sort, Subtotal, Label Subtotal, Insert row Teak Excel Programming 2 April 8th 04 04:14 PM


All times are GMT +1. The time now is 07:11 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"