LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA created formulas won't autocalculate

There is a problem, which i've been struggling with for some time now.
I've created a workbook with a macro that creates worksheets within
the workbook. The macro also enters formulas refering to cells of
other worksheets.
At first everything seems to work properly in the new worksheet.

The problem is that when I run the macro again to create another
worksheet, the formulas in the previous created worksheet fail to
autocalculate although "autocalculate" is on. Pressing <F9 doens't
work as well. The only thing that works is to enter the cell and then
press <enter. However the formulas in the new worksheet do work
properly, right until another new worksheet is created.

Has anybody encountered this problem, and is so.... any solutions?

Thanks in advance,

Frans Muller

The part of the VBA code that creates the worksheet:

Function Naar_vergelijk()
Dim Naam As String
Dim naam5 As String
If ActiveCell.Row < 6 Or ActiveCell.Row 98 Then
Show_Error ("Blad kan niet worden weergegeven, deze valt
buiten de selectie.")
Exit Function
End If
Naam = SetSheetName
naam5 = "Ink" + Right$(Naam, Len(Naam) - 4)
On Error GoTo Foutafhandeling
Sheets(Naam).Select
x = 0
If x = 0 Then Exit Function
Foutafhandeling:
Werkboek_beveiliging_opheffen
errorhandling Naam
Sheets(Naam).Visible = True
Sheets(naam5).Visible = True
Sheets(Naam).Select
Werkboek_beveiliging_zetten
End Function

Function errorhandling(naam3)
Dim naam4 As String
Dim teller As String
Dim teller2 As String

Resultaat_Beveiliging_Opheffen
naam4 = "Ink" + Right$(naam3, Len(naam3) - 4)
Select Case Error
Case Is = Error(9)
Sheets("Ink_standaard").Copy Befo=Sheets(1)
Sheets(1).name = naam4
Sheets(naam4).Move Befo=Sheets("resultaat")

Worksheets("rekenblad").Cells(3, 1).Value = formule1
Sheets("Verg_standaard").Copy Befo=Sheets(1)
Sheets(1).name = naam3
Sheets(naam3).Move Befo=Sheets("resultaat")

Worksheets(naam4).Range("A6:A42").NumberFormat = "General"
Worksheets(naam4).Range("C6:C42").NumberFormat = "General"
Worksheets(naam4).Range("E6:E42").NumberFormat = "General"
formule1 = "=" + naam3 + "!$A$"
formule2 = "=" + naam3 + "!$F$"
formule3 = "=" + naam3 + "!$N$"
Worksheets("rekenblad").Cells(1, 2).Value =
Worksheets("rekenblad").Cells(1, 1).Value + 5
teller2 = Worksheets("rekenblad").Cells(1, 2).Value
formule4 = "=Keuze!$E$"
onderwerp = "=Keuze!$D$"
For x = 9 To 45

formule = formule1 & x
Worksheets(naam4).Cells(x - 3, 1).Formula = formule

formule = formule2 & x
Worksheets(naam4).Cells(x - 3, 3).Formula = formule

formule = formule3 & x
Worksheets(naam4).Cells(x - 3, 5).Formula = formule
Next x
formule = onderwerp + teller2
Worksheets(naam3).Cells(4, 2).Formula = formule
formule = formule4 + teller2
Worksheets(naam3).Cells(5, 7).Formula = formule

Worksheets(naam4).Cells(3, 2).Formula = formule
Worksheets(naam4).Cells(3, 6).Formula =
Worksheets("rekenblad").Cells(1, 1).Value
Worksheets(naam3).Cells(2, 3).Formula =
Worksheets("rekenblad").Cells(1, 1).Value
Worksheets(naam4).Range("A6:A42").NumberFormat = ";;@"
Worksheets(naam4).Range("C6:C42").NumberFormat =
"#,##0.00_-;[Red]#,##0.00-;;@"
Worksheets(naam4).Range("E6:E42").NumberFormat =
"#,##0.00_-;[Red]#,##0.00-;;@"
regel = Worksheets("rekenblad").Cells(1, 1) + 9
Select Case regel
Case 10 To 38
regel1 = regel
Case 39 To 66
regel1 = regel + 2
Case 67 To 92
regel1 = regel + 4
End Select

Worksheets("resultaat").Cells(regel1, 1) = formule
Worksheets("resultaat").Cells(regel1, 3) = "=" + naam4 +
"!$C$57"
Worksheets("resultaat").Cells(regel1, 6) = "=" + naam4 +
"!$E$57"
Worksheets("resultaat").Cells(regel1, 10) = "=" + naam4 +
"!$C$59"

End Select
Resultaat_Beveiliging_Zetten
Nieuw_Beveiliging_Zetten naam3
Nieuw_Beveiliging_Zetten naam4
End Function
 
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
AutoCalculate Enable AutoCalculate Excel Discussion (Misc queries) 1 April 5th 10 07:52 PM
Show formulas and evaluaion with excel prgram created with VB Eddie Morris Excel Discussion (Misc queries) 1 October 30th 08 01:55 AM
Autocalculate Tom Excel Discussion (Misc queries) 5 August 4th 08 07:11 PM
Autocalculate Chris Excel Worksheet Functions 6 April 7th 05 04:18 PM
AutoCalculate LC[_2_] Excel Programming 1 August 6th 03 09:19 PM


All times are GMT +1. The time now is 03:16 AM.

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"