Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Keep calculation time down in large Workbooks

Dear All,

I have a really large workbook and am trying to keep the calculation time
down as much as possible. In one of the sheets I am trying to use the
following code each time there is a change in range "Input". The formulas to
be copied each time are sitting in cells G2 and H2.

It is working fine when using dropdown boxes because the cursor will stay in
the same cell. However when entering the new data in "Input" and pressing
Enter or Down arrow the formula will be copied onto the row immediately
below. When I press Up arrow the formula will be copied onto the row
immediately above.

When pressing left or right arrow nothing happens.

Any help would be much appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ThisCell As Range

For Each ThisCell In Selection.Cells
If Not Intersect(ThisCell, [Input]) Is Nothing Then
[G2:H2].Copy
ThisCell.Offset(0, 1).PasteSpecial xlPasteFormulas
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0, 1).Copy
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0,
1).PasteSpecial xlPasteValues
End If
Next ThisCell

End Sub

--
Regards,

Martin
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Keep calculation time down in large Workbooks

Shouldn't you be copying relative to Target, rather than selection.

--
Regards,
Tom Ogilvy


"Martin" wrote:

Dear All,

I have a really large workbook and am trying to keep the calculation time
down as much as possible. In one of the sheets I am trying to use the
following code each time there is a change in range "Input". The formulas to
be copied each time are sitting in cells G2 and H2.

It is working fine when using dropdown boxes because the cursor will stay in
the same cell. However when entering the new data in "Input" and pressing
Enter or Down arrow the formula will be copied onto the row immediately
below. When I press Up arrow the formula will be copied onto the row
immediately above.

When pressing left or right arrow nothing happens.

Any help would be much appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ThisCell As Range

For Each ThisCell In Selection.Cells
If Not Intersect(ThisCell, [Input]) Is Nothing Then
[G2:H2].Copy
ThisCell.Offset(0, 1).PasteSpecial xlPasteFormulas
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0, 1).Copy
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0,
1).PasteSpecial xlPasteValues
End If
Next ThisCell

End Sub

--
Regards,

Martin

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default Keep calculation time down in large Workbooks

Many thanks Tom. You are absolutely right.
--
Regards,

Martin


"Tom Ogilvy" wrote:

Shouldn't you be copying relative to Target, rather than selection.

--
Regards,
Tom Ogilvy


"Martin" wrote:

Dear All,

I have a really large workbook and am trying to keep the calculation time
down as much as possible. In one of the sheets I am trying to use the
following code each time there is a change in range "Input". The formulas to
be copied each time are sitting in cells G2 and H2.

It is working fine when using dropdown boxes because the cursor will stay in
the same cell. However when entering the new data in "Input" and pressing
Enter or Down arrow the formula will be copied onto the row immediately
below. When I press Up arrow the formula will be copied onto the row
immediately above.

When pressing left or right arrow nothing happens.

Any help would be much appreciated.

Private Sub Worksheet_Change(ByVal Target As Range)

Dim ThisCell As Range

For Each ThisCell In Selection.Cells
If Not Intersect(ThisCell, [Input]) Is Nothing Then
[G2:H2].Copy
ThisCell.Offset(0, 1).PasteSpecial xlPasteFormulas
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0, 1).Copy
Range(ThisCell, ThisCell.Offset(0, 1)).Offset(0,
1).PasteSpecial xlPasteValues
End If
Next ThisCell

End Sub

--
Regards,

Martin

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
Large Function in a calculation Lyn new at access Excel Discussion (Misc queries) 7 May 16th 07 09:18 PM
Large workbooks donjmcdonald Excel Discussion (Misc queries) 2 December 11th 06 10:39 PM
Non-calculation in large workbook Edward Excel Discussion (Misc queries) 0 June 5th 06 07:13 PM
Mortgage calculation after a large extra payment Gary Wachs Excel Discussion (Misc queries) 6 April 16th 06 08:55 AM
Mortgage calculation after a large extra payment Gary Wachs Excel Worksheet Functions 4 April 16th 06 02:01 AM


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