Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default How to reduce selection

I have seen many posts that says not to use "SELECT" and is almost
un-necessary. Following code is mainly based on the selection only.

Sheets("LIST").Range("A:C").Copy Destination:=SHT1.Range("A1")
Set ITRN = Sheets("In").Range("J:J")
Set QTRN = Sheets("In").Range("M:M")
Range("D2").Select
Do While Not IsEmpty(ActiveCell.Offset(0, -3).Value)
ActiveCell.Value = Application.WorksheetFunction.SumIf(ITRN,
ActiveCell.Offset(0, -3), QTRN)
ActiveCell.Offset(1, 0).Select
Loop
Set ITRN = Nothing
Set QTRN = Nothing

This code is being repeated 8 times for looping around 4000++ rows
to complete the report generation.

Question:
How can I reduce the "SELECT" part to speed up the macro running?

Any help is appreciated.
Bimal.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to reduce selection

Sheets("LIST").Range("A:C").Copy Destination:=SHT1.Range("A1")
Set ITRN = Sheets("In").Range("J:J")
Set QTRN = Sheets("In").Range("M:M")
set cell = Range("D2")
Do While Not IsEmpty(cell.Offset(0, -3).Value)
cell.Value = Application.WorksheetFunction.SumIf(ITRN, _
Cell.Offset(0, -3), QTRN)
set cell = Cell.Offset(1, 0)
Loop
Set ITRN = Nothing
Set QTRN = Nothing

--
Regards,
Tom Ogilvy


"Bimal" wrote in message
m...
I have seen many posts that says not to use "SELECT" and is almost
un-necessary. Following code is mainly based on the selection only.

Sheets("LIST").Range("A:C").Copy Destination:=SHT1.Range("A1")
Set ITRN = Sheets("In").Range("J:J")
Set QTRN = Sheets("In").Range("M:M")
Range("D2").Select
Do While Not IsEmpty(ActiveCell.Offset(0, -3).Value)
ActiveCell.Value = Application.WorksheetFunction.SumIf(ITRN,
ActiveCell.Offset(0, -3), QTRN)
ActiveCell.Offset(1, 0).Select
Loop
Set ITRN = Nothing
Set QTRN = Nothing

This code is being repeated 8 times for looping around 4000++ rows
to complete the report generation.

Question:
How can I reduce the "SELECT" part to speed up the macro running?

Any help is appreciated.
Bimal.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to reduce selection

Hi Bimal,


Try this

Dim i As Long

Application.ScreenUpdating = False
Worksheets("LIST").Range("A:C").Copy Destination:=SHT1.Range("A1")
Set ITRN = Sheets("In").Range("J:J")
Set QTRN = Sheets("In").Range("M:M")
i = 2
Do While Not IsEmpty(Cells(i, "D").Offset(0, -3).Value)
With Cells(i, "D")
.Value = Application.WorksheetFunction.SumIf(ITRN,
..Offset(0, -3), QTRN)
End With
i = i + 1
Loop
Application.ScreenUpdating = True
Set ITRN = Nothing
Set QTRN = Nothing



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bimal" wrote in message
m...
I have seen many posts that says not to use "SELECT" and is almost
un-necessary. Following code is mainly based on the selection only.

Sheets("LIST").Range("A:C").Copy Destination:=SHT1.Range("A1")
Set ITRN = Sheets("In").Range("J:J")
Set QTRN = Sheets("In").Range("M:M")
Range("D2").Select
Do While Not IsEmpty(ActiveCell.Offset(0, -3).Value)
ActiveCell.Value = Application.WorksheetFunction.SumIf(ITRN,
ActiveCell.Offset(0, -3), QTRN)
ActiveCell.Offset(1, 0).Select
Loop
Set ITRN = Nothing
Set QTRN = Nothing

This code is being repeated 8 times for looping around 4000++ rows
to complete the report generation.

Question:
How can I reduce the "SELECT" part to speed up the macro running?

Any help is appreciated.
Bimal.



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
Reduce balance nat Excel Discussion (Misc queries) 2 March 12th 10 12:14 AM
Limiting selection in a cell AND linking that selection to a list Lisa Excel Discussion (Misc queries) 1 July 28th 09 05:00 PM
How to Reduce value in a column by 5%? capxc Excel Discussion (Misc queries) 11 July 14th 08 06:51 PM
Copy Selection - Transpose Selection - Delete Selection Uninvisible Excel Discussion (Misc queries) 2 October 23rd 07 04:18 PM
Reduce # of pages CDAK Excel Discussion (Misc queries) 1 June 16th 05 09:18 PM


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