Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default Excel Calculating problem

when i programatically copied and pasted a formula on a worksheet, the entire
worksheet now refuses to calculate all formulas - even simple ones, entered
manually, such as = 1+2. 0 is displayed as the result.

Cell formatting is set to standard Number, 0 Decimals and (1,234) for
negative.


Here's the code I used to copy and paste the formula:

with WorkSheetObject
.cells(9,5).formula = "=E41+E73+E105"

.Cells(9, 5).Copy
.Range(.Cells(9, 6), .Cells(9, 42)).PasteSpecial _
Paste:=xlPasteFormulasAndNumberFormats
end with

All was working fine until I ran these two lines. Had same issue earlier on
different sheet using sumif after programatically using PasteSpecial,
developed a workaround but I really need this formula to work on this sheet

Am Using Excel 2002 SP3 in WIn XP Pro. No other Office versions have been
on machine. Calculation is set to Automatic and forcing re-calulation has no
effect (Calc Now "F9" or Calc Sheet).

Any helpful comments are appreciated.

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Excel Calculating problem

Sub hskf()
With ActiveSheet
.Cells(9, 5).Formula = "=E41+E73+E105"

.Cells(9, 5).Copy
.Range(.Cells(9, 6), .Cells(9, 42)).PasteSpecial _
Paste:=xlPasteFormulasAndNumberFormats
End With

End Sub


--
Gary''s Student - gsnu200790
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Excel Calculating problem

aI don't see any significant difference between what I originally worte and
the response. code was already in a proc (assumed) and WorkSheetObject refers
to a worksheet (and must) other than the activesheet.

When I copy the worksheet (drag and drop) to a new sheet it starts to
calculate.

"Gary''s Student" wrote:

Sub hskf()
With ActiveSheet
.Cells(9, 5).Formula = "=E41+E73+E105"

.Cells(9, 5).Copy
.Range(.Cells(9, 6), .Cells(9, 42)).PasteSpecial _
Paste:=xlPasteFormulasAndNumberFormats
End With

End Sub


--
Gary''s Student - gsnu200790

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Excel Calculating problem

I've seen some posts that say that calculation won't occur even when calculation
is set to automatic.

One suggestion that seems to work is to select all the cells
edit|Replace
what: = (equal sign)
with: =
replace all

It seems to wake up excel's calculation engine.

I would try that first, then try your code once more.

If that doesn't work, maybe you could include the same technique in your code:

Option Explicit
Sub testme01()

Dim WorkSheetObject As Worksheet

Set WorkSheetObject = ActiveSheet

With WorkSheetObject
With .Range("E9").Resize(1, 38)
.Formula = "=E41+E73+E105"
Application.Calculate
'if that didn't work, "reenter" the formulas
.Replace what:="=", replacement:="=", Lookat:=xlPart, _
searchorder:=xlByColumns, MatchCase:=False
End With
End With
End Sub


JohnS-BelmontNC wrote:

when i programatically copied and pasted a formula on a worksheet, the entire
worksheet now refuses to calculate all formulas - even simple ones, entered
manually, such as = 1+2. 0 is displayed as the result.

Cell formatting is set to standard Number, 0 Decimals and (1,234) for
negative.

Here's the code I used to copy and paste the formula:

with WorkSheetObject
.cells(9,5).formula = "=E41+E73+E105"

.Cells(9, 5).Copy
.Range(.Cells(9, 6), .Cells(9, 42)).PasteSpecial _
Paste:=xlPasteFormulasAndNumberFormats
end with

All was working fine until I ran these two lines. Had same issue earlier on
different sheet using sumif after programatically using PasteSpecial,
developed a workaround but I really need this formula to work on this sheet

Am Using Excel 2002 SP3 in WIn XP Pro. No other Office versions have been
on machine. Calculation is set to Automatic and forcing re-calulation has no
effect (Calc Now "F9" or Calc Sheet).

Any helpful comments are appreciated.


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Excel Calculating problem

I've since copied the sheet and programmed around PasteSpecial using .Copy
and .Paste Destination:= .Range(...)

After this I created a code line to format the copied range useing
..Range(...).NumberFormat = "##,###,##0"

This seems to have solved the problem as a workaround. Unfortunately, this
section of code will get a good workout because it will be re-run each time
as indivduals add a records to a previous sheet.

I've gone back to the old non-working sheet and it will now re-calculate. It
even works programatically. Lord know why!

Since this workbook will be used by others and many values will be
dynamically updated, I can't take the chance of having it not work at least
not at this stage, so I use the workaround. Perhaps when I move to Office
2007 it wil be different.

I assume this is a bug in Excel 2002 or VBA.

Thanks for your input.

"Dave Peterson" wrote:

I've seen some posts that say that calculation won't occur even when calculation
is set to automatic.

One suggestion that seems to work is to select all the cells
edit|Replace
what: = (equal sign)
with: =
replace all

It seems to wake up excel's calculation engine.

I would try that first, then try your code once more.

If that doesn't work, maybe you could include the same technique in your code:

Option Explicit
Sub testme01()

Dim WorkSheetObject As Worksheet

Set WorkSheetObject = ActiveSheet

With WorkSheetObject
With .Range("E9").Resize(1, 38)
.Formula = "=E41+E73+E105"
Application.Calculate
'if that didn't work, "reenter" the formulas
.Replace what:="=", replacement:="=", Lookat:=xlPart, _
searchorder:=xlByColumns, MatchCase:=False
End With
End With
End Sub


JohnS-BelmontNC wrote:

when i programatically copied and pasted a formula on a worksheet, the entire
worksheet now refuses to calculate all formulas - even simple ones, entered
manually, such as = 1+2. 0 is displayed as the result.

Cell formatting is set to standard Number, 0 Decimals and (1,234) for
negative.

Here's the code I used to copy and paste the formula:

with WorkSheetObject
.cells(9,5).formula = "=E41+E73+E105"

.Cells(9, 5).Copy
.Range(.Cells(9, 6), .Cells(9, 42)).PasteSpecial _
Paste:=xlPasteFormulasAndNumberFormats
end with

All was working fine until I ran these two lines. Had same issue earlier on
different sheet using sumif after programatically using PasteSpecial,
developed a workaround but I really need this formula to work on this sheet

Am Using Excel 2002 SP3 in WIn XP Pro. No other Office versions have been
on machine. Calculation is set to Automatic and forcing re-calulation has no
effect (Calc Now "F9" or Calc Sheet).

Any helpful comments are appreciated.


--

Dave Peterson

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
Problem calculating with a SUMIF juliejg1 Excel Worksheet Functions 7 March 6th 08 08:26 PM
microsoft excel 2000 calculating problem [email protected] Excel Discussion (Misc queries) 1 December 19th 07 10:26 AM
Problem Plotting/Calculating with #NA excelBRISKbaby Excel Discussion (Misc queries) 5 June 8th 07 10:14 PM
Time calculating problem ru1peh Excel Discussion (Misc queries) 2 August 5th 06 09:01 AM
Problem with calculating time Lee Excel Discussion (Misc queries) 9 March 14th 06 08:53 PM


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