Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Code works but is slow except when....

Hello friends,

My code works but it is slow except when if I click on another
application (ie Internet Explorer) then it speeds up to the expected
performance. Any thoughts...


Sub ImportDash()

Dim MyFile, cell, m, n, bb, zs, zt As Variant
Dim mybook As Workbook
Dim i As Long
Dim Sh As Worksheet
Dim DexArray(1 To 8)
Dim RangeArray(1 To 8)

'Load all of the impacted workbooks into DexArray
DexArray(1) = "CNC-IBWC"
DexArray(2) = "CNC-SALES"
DexArray(3) = "CNC-HFC"
DexArray(4) = "MAK-SALES"
DexArray(5) = "MAK-HFC"
DexArray(6) = "MOP-IBWC"
DexArray(7) = "MOP-RQ"
DexArray(8) = "MOP CS Team"

'Load all of the impacted Ranges into RangeArray
RangeArray(1) = "a104:af104"
RangeArray(2) = "a118:ab118"
RangeArray(3) = "a125:q125"
RangeArray(4) = "a132:ac132"
RangeArray(5) = "a137:n137"
RangeArray(6) = "a146:af146"
RangeArray(7) = "a153:z153"
RangeArray(8) = "a158:l158"

'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Save workbook name for quick reference
Set zs = ThisWorkbook

' Ask the user for the file name to open.
MyFile = Application.GetOpenFilename(filefilter:="Excel
Files(*.xls),*.xls")
If MyFile = False Then
MsgBox "You didn't select correct file"
Exit Sub
End If

' Open the Text file with the OpenText method and parses data.
Workbooks.Open Filename:=MyFile, Origin:=xlWindows, ReadOnly:=True,
UpdateLinks:=False
zt = ActiveWorkbook.Name


'Again save imported workbook name for quick reference
Set mybook = ActiveWorkbook

'Prepare to loop thur arrays
For i = 1 To 8
zs.Sheets("main").Activate
For Each cell In Range(RangeArray(i))
'Find column location for data
If cell < "" Then
m = cell.Value
n = cell.Column

mybook.Sheets(DexArray(i)).Activate
'Indentify data range using bb,aa strings and copy the
data over for imported sheet
bb = Cells.Find(what:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
Range(Cells(7, m), Cells(bb, m)).Select
Selection.Copy
zs.Sheets(DexArray(i)).Activate
Cells(7, n).Select
Selection.PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False


zs.Sheets("main").Activate
End If
Next cell


Next i

end sub

Thanks in advance.... Dex

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 168
Default Code works but is slow except when....

I noticed you have the following line in your code that is remmed out.
'Application.ScreenUpdating = False

Add to the beginning of your code:
Application.ScreenUpdating = False

Add to the end of your code:
Application.ScreenUpdating = True

HTH,
Paul


wrote in message
ups.com...
Hello friends,

My code works but it is slow except when if I click on another
application (ie Internet Explorer) then it speeds up to the expected
performance. Any thoughts...


Sub ImportDash()

Dim MyFile, cell, m, n, bb, zs, zt As Variant
Dim mybook As Workbook
Dim i As Long
Dim Sh As Worksheet
Dim DexArray(1 To 8)
Dim RangeArray(1 To 8)

'Load all of the impacted workbooks into DexArray
DexArray(1) = "CNC-IBWC"
DexArray(2) = "CNC-SALES"
DexArray(3) = "CNC-HFC"
DexArray(4) = "MAK-SALES"
DexArray(5) = "MAK-HFC"
DexArray(6) = "MOP-IBWC"
DexArray(7) = "MOP-RQ"
DexArray(8) = "MOP CS Team"

'Load all of the impacted Ranges into RangeArray
RangeArray(1) = "a104:af104"
RangeArray(2) = "a118:ab118"
RangeArray(3) = "a125:q125"
RangeArray(4) = "a132:ac132"
RangeArray(5) = "a137:n137"
RangeArray(6) = "a146:af146"
RangeArray(7) = "a153:z153"
RangeArray(8) = "a158:l158"

'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Save workbook name for quick reference
Set zs = ThisWorkbook

' Ask the user for the file name to open.
MyFile = Application.GetOpenFilename(filefilter:="Excel
Files(*.xls),*.xls")
If MyFile = False Then
MsgBox "You didn't select correct file"
Exit Sub
End If

' Open the Text file with the OpenText method and parses data.
Workbooks.Open Filename:=MyFile, Origin:=xlWindows, ReadOnly:=True,
UpdateLinks:=False
zt = ActiveWorkbook.Name


'Again save imported workbook name for quick reference
Set mybook = ActiveWorkbook

'Prepare to loop thur arrays
For i = 1 To 8
zs.Sheets("main").Activate
For Each cell In Range(RangeArray(i))
'Find column location for data
If cell < "" Then
m = cell.Value
n = cell.Column

mybook.Sheets(DexArray(i)).Activate
'Indentify data range using bb,aa strings and copy the
data over for imported sheet
bb = Cells.Find(what:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
Range(Cells(7, m), Cells(bb, m)).Select
Selection.Copy
zs.Sheets(DexArray(i)).Activate
Cells(7, n).Select
Selection.PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False


zs.Sheets("main").Activate
End If
Next cell


Next i

end sub

Thanks in advance.... Dex



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Code works but is slow except when....

Thanks but I tried that already, does not help .... Rimmed in out to
see if I could uncover the issue.


PCLIVE wrote:
I noticed you have the following line in your code that is remmed out.
'Application.ScreenUpdating = False

Add to the beginning of your code:
Application.ScreenUpdating = False

Add to the end of your code:
Application.ScreenUpdating = True

HTH,
Paul


wrote in message
ups.com...
Hello friends,

My code works but it is slow except when if I click on another
application (ie Internet Explorer) then it speeds up to the expected
performance. Any thoughts...


Sub ImportDash()

Dim MyFile, cell, m, n, bb, zs, zt As Variant
Dim mybook As Workbook
Dim i As Long
Dim Sh As Worksheet
Dim DexArray(1 To 8)
Dim RangeArray(1 To 8)

'Load all of the impacted workbooks into DexArray
DexArray(1) = "CNC-IBWC"
DexArray(2) = "CNC-SALES"
DexArray(3) = "CNC-HFC"
DexArray(4) = "MAK-SALES"
DexArray(5) = "MAK-HFC"
DexArray(6) = "MOP-IBWC"
DexArray(7) = "MOP-RQ"
DexArray(8) = "MOP CS Team"

'Load all of the impacted Ranges into RangeArray
RangeArray(1) = "a104:af104"
RangeArray(2) = "a118:ab118"
RangeArray(3) = "a125:q125"
RangeArray(4) = "a132:ac132"
RangeArray(5) = "a137:n137"
RangeArray(6) = "a146:af146"
RangeArray(7) = "a153:z153"
RangeArray(8) = "a158:l158"

'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Save workbook name for quick reference
Set zs = ThisWorkbook

' Ask the user for the file name to open.
MyFile = Application.GetOpenFilename(filefilter:="Excel
Files(*.xls),*.xls")
If MyFile = False Then
MsgBox "You didn't select correct file"
Exit Sub
End If

' Open the Text file with the OpenText method and parses data.
Workbooks.Open Filename:=MyFile, Origin:=xlWindows, ReadOnly:=True,
UpdateLinks:=False
zt = ActiveWorkbook.Name


'Again save imported workbook name for quick reference
Set mybook = ActiveWorkbook

'Prepare to loop thur arrays
For i = 1 To 8
zs.Sheets("main").Activate
For Each cell In Range(RangeArray(i))
'Find column location for data
If cell < "" Then
m = cell.Value
n = cell.Column

mybook.Sheets(DexArray(i)).Activate
'Indentify data range using bb,aa strings and copy the
data over for imported sheet
bb = Cells.Find(what:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
Range(Cells(7, m), Cells(bb, m)).Select
Selection.Copy
zs.Sheets(DexArray(i)).Activate
Cells(7, n).Select
Selection.PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False


zs.Sheets("main").Activate
End If
Next cell


Next i

end sub

Thanks in advance.... Dex


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Code works but is slow except when....

If you can drop all the .Selects it would help.

NickHK

wrote in message
ups.com...
Hello friends,

My code works but it is slow except when if I click on another
application (ie Internet Explorer) then it speeds up to the expected
performance. Any thoughts...


Sub ImportDash()

Dim MyFile, cell, m, n, bb, zs, zt As Variant
Dim mybook As Workbook
Dim i As Long
Dim Sh As Worksheet
Dim DexArray(1 To 8)
Dim RangeArray(1 To 8)

'Load all of the impacted workbooks into DexArray
DexArray(1) = "CNC-IBWC"
DexArray(2) = "CNC-SALES"
DexArray(3) = "CNC-HFC"
DexArray(4) = "MAK-SALES"
DexArray(5) = "MAK-HFC"
DexArray(6) = "MOP-IBWC"
DexArray(7) = "MOP-RQ"
DexArray(8) = "MOP CS Team"

'Load all of the impacted Ranges into RangeArray
RangeArray(1) = "a104:af104"
RangeArray(2) = "a118:ab118"
RangeArray(3) = "a125:q125"
RangeArray(4) = "a132:ac132"
RangeArray(5) = "a137:n137"
RangeArray(6) = "a146:af146"
RangeArray(7) = "a153:z153"
RangeArray(8) = "a158:l158"

'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
'Save workbook name for quick reference
Set zs = ThisWorkbook

' Ask the user for the file name to open.
MyFile = Application.GetOpenFilename(filefilter:="Excel
Files(*.xls),*.xls")
If MyFile = False Then
MsgBox "You didn't select correct file"
Exit Sub
End If

' Open the Text file with the OpenText method and parses data.
Workbooks.Open Filename:=MyFile, Origin:=xlWindows, ReadOnly:=True,
UpdateLinks:=False
zt = ActiveWorkbook.Name


'Again save imported workbook name for quick reference
Set mybook = ActiveWorkbook

'Prepare to loop thur arrays
For i = 1 To 8
zs.Sheets("main").Activate
For Each cell In Range(RangeArray(i))
'Find column location for data
If cell < "" Then
m = cell.Value
n = cell.Column

mybook.Sheets(DexArray(i)).Activate
'Indentify data range using bb,aa strings and copy the
data over for imported sheet
bb = Cells.Find(what:="*", After:=[A1],
SearchDirection:=xlPrevious).Row
Range(Cells(7, m), Cells(bb, m)).Select
Selection.Copy
zs.Sheets(DexArray(i)).Activate
Cells(7, n).Select
Selection.PasteSpecial
Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False


zs.Sheets("main").Activate
End If
Next cell


Next i

end sub

Thanks in advance.... Dex



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
Code works, but is slow EMoe[_92_] Excel Programming 7 December 25th 05 09:08 PM
Code somewhat works. Please help? jsc3489 Excel Programming 4 December 2nd 05 07:51 PM
Why this code works and other do not? Newbie here. [email protected] Excel Programming 2 September 10th 05 01:12 PM
Code works for any WBK except the PMW Mark Tangard[_3_] Excel Programming 3 July 17th 05 11:54 AM
Why won't this code works ksnapp[_37_] Excel Programming 6 April 1st 04 01:44 PM


All times are GMT +1. The time now is 10:50 PM.

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"