Click here to Skip to main content
16,010,488 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Mdi inside Mdi Pin
Samir Ibrahim21-May-09 3:11
Samir Ibrahim21-May-09 3:11 
GeneralRe: Mdi inside Mdi Pin
Henry Minute21-May-09 6:38
Henry Minute21-May-09 6:38 
GeneralRe: Mdi inside Mdi Pin
Samir Ibrahim21-May-09 7:09
Samir Ibrahim21-May-09 7:09 
GeneralRe: Mdi inside Mdi Pin
Henry Minute21-May-09 7:17
Henry Minute21-May-09 7:17 
AnswerRe: Mdi inside Mdi Pin
Dave Kreskowiak21-May-09 2:00
mveDave Kreskowiak21-May-09 2:00 
GeneralRe: Mdi inside Mdi Pin
Samir Ibrahim21-May-09 3:03
Samir Ibrahim21-May-09 3:03 
GeneralRe: Mdi inside Mdi Pin
Dave Kreskowiak21-May-09 3:43
mveDave Kreskowiak21-May-09 3:43 
Question#VALUE errors whenever I turn my back Pin
aastudent20-May-09 20:27
aastudent20-May-09 20:27 
Hi
I'm am using VBA functions in excel to calculate individual cell values. These work fine when the sheet wherein they are contained is active, but sometimes if I navigate to a different sheet and back again all I get is #VALUE in every cell. Interestingly this especially seems to happen when I open another spreadsheet (one on which Spreadsheet 1 depends for a number of values - none of which precede the cells giving the #VALUE errors though). What is probably most annoying is that it happens sometimes and sometimes not and I can't seem to identify why.

Here is a code snippet. This wasn't written by me, but it is relatively simple so I am slightly stumped here:


Public Function GLA(Cat As Integer, Age As Double, Sal As Double, run As Integer, chk As Double)
Application.Volatile

Dim Mult As Double
Dim Flat As Double
Dim MaxGLA As Double
Dim CeaseAge As Double
Dim startRow As Integer
Dim Column As Integer
Dim Retention As Double

exist = Sheets("Parm").Cells(21, 4).Value

If exist = 1 Then

Column = IIf(run = 0, 3, 9)
startRow = 32

Mult = Sheets("Parm").Cells(startRow + 0, Column + Cat).Value
MaxGLA = Sheets("Parm").Cells(startRow + 1, Column + Cat).Value
Flat = Sheets("Parm").Cells(startRow + 2, Column + Cat).Value
CeaseAge = Sheets("Parm").Cells(startRow + 3, Column + Cat).Value
Retention = Sheets("Parm").Cells(startRow + 5, Column + Cat).Value

MaxGLA = IIf(MaxGLA = 0, 100000000, MaxGLA)

If Mult = 99 Then
Mult = Sheets("AgeBands").Cells(Age - 9, Column + Cat).Value
End If

GLA = Mult * Sal + Flat
GLA = IIf(GLA > MaxGLA, MaxGLA, GLA)
GLA = IIf(GLA > Retention, GLA - Retention, 0)
GLA = IIf(Age > CeaseAge, 0, GLA)
End If


End Function

This is then called from each cell as =GLA(...parameters)

Another point: I added the Application.Volatile part because calculations were constantly "lagging behind". I.e. unbeknownst to me the cells in question (and all subsequently dependent cells) were not updating their calculations.


Much appreciated

Karl
AnswerRe: #VALUE errors whenever I turn my back Pin
Dave Kreskowiak21-May-09 1:58
mveDave Kreskowiak21-May-09 1:58 
GeneralRe: #VALUE errors whenever I turn my back Pin
aastudent21-May-09 2:12
aastudent21-May-09 2:12 
GeneralRe: #VALUE errors whenever I turn my back Pin
Dave Kreskowiak21-May-09 3:40
mveDave Kreskowiak21-May-09 3:40 
GeneralRe: #VALUE errors whenever I turn my back Pin
aastudent21-May-09 4:45
aastudent21-May-09 4:45 
AnswerRe: #VALUE errors whenever I turn my back Pin
EliottA21-May-09 3:05
EliottA21-May-09 3:05 
QuestionGet All Object Property Name and Value Pin
Samir Ibrahim20-May-09 20:24
Samir Ibrahim20-May-09 20:24 
AnswerRe: Get All Object Property Name and Value Pin
TheMrProgrammer20-May-09 21:29
TheMrProgrammer20-May-09 21:29 
GeneralRe: Get All Object Property Name and Value Pin
Samir Ibrahim20-May-09 21:50
Samir Ibrahim20-May-09 21:50 
GeneralRe: Get All Object Property Name and Value Pin
Dave Kreskowiak21-May-09 1:53
mveDave Kreskowiak21-May-09 1:53 
GeneralRe: Get All Object Property Name and Value Pin
Samir Ibrahim21-May-09 21:36
Samir Ibrahim21-May-09 21:36 
GeneralRe: Get All Object Property Name and Value Pin
Dave Kreskowiak22-May-09 12:53
mveDave Kreskowiak22-May-09 12:53 
GeneralRe: Get All Object Property Name and Value Pin
Samir Ibrahim24-May-09 20:56
Samir Ibrahim24-May-09 20:56 
GeneralRe: Get All Object Property Name and Value Pin
Dave Kreskowiak25-May-09 6:27
mveDave Kreskowiak25-May-09 6:27 
GeneralRe: Get All Object Property Name and Value Pin
Samir Ibrahim25-May-09 6:40
Samir Ibrahim25-May-09 6:40 
Questionany errors here?? Pin
TheMrProgrammer20-May-09 9:02
TheMrProgrammer20-May-09 9:02 
AnswerRe: any errors here?? [modified] Pin
Alan N20-May-09 9:54
Alan N20-May-09 9:54 
AnswerRe: any errors here?? Pin
Dave Kreskowiak20-May-09 10:12
mveDave Kreskowiak20-May-09 10:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.