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 working very slow

Hi,

I have this code which works very very slow and hangs sometimes a
well...... can something be done ???

'MsgBox "Please wait while data is UPLOADED in the database, Press O
and wait for a few minutes!!!"
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False


''remove blank rows in enter data sheet
'
'Sheets("Enter Data").Select
'Dim column_with_blanks As Long
'column_with_blanks = 1
'On Error Resume Next 'In case there are no blank rows
'Columns(column_with_blanks).SpecialCells(xlCellTy peBlanks).EntireRow.Delete
'On Error GoTo 0
'
''Shift recently fed data from "enter data" sheet to "database" sheet
'
' Sheets("Enter Data").Select
' Range("E2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Selection.Copy
' Sheets("Database").Select
' Range("A2").Select
' Selection.Insert Shift:=xlDown
' Sheets("Enter Data").Select
' Range("A2:D2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Application.CutCopyMode = False
' Selection.Copy
' Sheets("Database").Select
' Range("B2").Select
' Selection.Insert Shift:=xlDown
'
''Remove Dup Names
' Cells.Sort Key1:=Range("A1")
' totalrows = ActiveSheet.UsedRange.Rows.Count
' For Row = totalrows To 2 Step -1
' If Cells(Row, 1).Value = Cells(Row - 1, 1).Value Then
' Rows(Row).Delete
' End If
' Next Row
'
'
' Cells.Select
' Selection.Sort Key1:=Range("a1"), Order1:=xlAscending
Header:=xlNo, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'pasting data in the reports sheet

Application.CutCopyMode = False
Sheets("Database").Select
Range("A1:B1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Reports").Select
Range("b38").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Sheets("Database").Select
Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Reports").Select
Range("d38").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

'arranging data TL wise
Range("b38:d38").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("d38"), Order1:=xlAscending
Key2:=Range("c38" _
), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1
MatchCase:= _
False, Orientation:=xlTopToBottom

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Calculate


MsgBox "Data is updated now!!!

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default macro working very slow

For one thing, try to get rid of the selections

range("a2").select
selection.copy
range("b2").select
selection.paste
can be
sheets("sheet1").range("a2").copy sheets("sheet2").range("b2")
or if you just want the values
sheets("sheet2").range("b2")=sheets("sheet1").rang e("a2")

--
Don Guillett
SalesAid Software

"paritoshmehta " wrote in
message ...
Hi,

I have this code which works very very slow and hangs sometimes as
well...... can something be done ???

'MsgBox "Please wait while data is UPLOADED in the database, Press OK
and wait for a few minutes!!!"
'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Application.EnableEvents = False


''remove blank rows in enter data sheet
'
'Sheets("Enter Data").Select
'Dim column_with_blanks As Long
'column_with_blanks = 1
'On Error Resume Next 'In case there are no blank rows

'Columns(column_with_blanks).SpecialCells(xlCellTy peBlanks).EntireRow.Delete
'On Error GoTo 0
'
''Shift recently fed data from "enter data" sheet to "database" sheet
'
' Sheets("Enter Data").Select
' Range("E2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Selection.Copy
' Sheets("Database").Select
' Range("A2").Select
' Selection.Insert Shift:=xlDown
' Sheets("Enter Data").Select
' Range("A2:D2").Select
' Range(Selection, Selection.End(xlDown)).Select
' Application.CutCopyMode = False
' Selection.Copy
' Sheets("Database").Select
' Range("B2").Select
' Selection.Insert Shift:=xlDown
'
''Remove Dup Names
' Cells.Sort Key1:=Range("A1")
' totalrows = ActiveSheet.UsedRange.Rows.Count
' For Row = totalrows To 2 Step -1
' If Cells(Row, 1).Value = Cells(Row - 1, 1).Value Then
' Rows(Row).Delete
' End If
' Next Row
'
'
' Cells.Select
' Selection.Sort Key1:=Range("a1"), Order1:=xlAscending,
Header:=xlNo, _
' OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom

'pasting data in the reports sheet

Application.CutCopyMode = False
Sheets("Database").Select
Range("A1:B1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Reports").Select
Range("b38").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
Sheets("Database").Select
Range("D1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Reports").Select
Range("d38").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False

'arranging data TL wise
Range("b38:d38").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Sort Key1:=Range("d38"), Order1:=xlAscending,
Key2:=Range("c38" _
), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase:= _
False, Orientation:=xlTopToBottom

Application.EnableEvents = True
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Calculate


MsgBox "Data is updated now!!!"


---
Message posted from
http://www.ExcelForum.com/



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
slow macro :)[_2_] Excel Discussion (Misc queries) 1 March 3rd 10 02:41 PM
Macro is very slow jlclyde Excel Discussion (Misc queries) 2 September 29th 08 04:43 PM
Macro is amazingly SLOW...Need help anshu[_2_] Excel Discussion (Misc queries) 7 July 16th 07 01:03 PM
Excel working very slow Krishna Kumar L Excel Discussion (Misc queries) 2 July 9th 07 10:48 AM
excel 2003 slow when working with excel 2000 files michel Excel Discussion (Misc queries) 0 November 28th 05 03:40 PM


All times are GMT +1. The time now is 11:01 AM.

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

About Us

"It's about Microsoft Excel"