I know the normal way of doing this. The reason i'm doing it through a macro
is because i want this in a calculation to be accessible for people (I want
the cell to read L43*0.05 instead of IF(blabla=empty;"";L43*0,05).
I am currently using a sheet_activate code (the following
Private Sub Worksheet_Activate()
If Range("D32").Value <> "" Then
Range("D33").Value = Range("N5").Value
Range("D34").Value = Worksheets("Invulblad").Range("N23").Value
Range("D36").Value = "=D33*D34"
Range("D37").Value = Worksheets("Invulblad").Range("AF9").Value
Range("D39").Value = "=D36*D37"
Range("D40").Value = Worksheets("Invulblad").Range("AE51").Value
Range("D41").Value = Worksheets("Invulblad").Range("K43").Value
Range("D43").Value = "=D39+D40+D41"
Range("D45").Value = Worksheets("Invulblad").Range("AA47").Value * L43
Range("D46").Value = Worksheets("Invulblad").Range("AA48").Value * L43
Range("D47").Value = Worksheets("Invulblad").Range("AA49").Value * L43
Range("D48").Value = Worksheets("Invulblad").Range("AA50").Value * L43
Range("D50").Value = "=D43+D46+D47+D48+D49"
Range("D51").Value = Worksheets("Invulblad").Range("AF25").Value
Range("D53").Value = "=MAX(D51
52)"
Range("D55").Value = (Range("D53").Value /
Worksheets("Invulblad").Range("AA51")) - Range("D53").Value
Range("D57").Value = "=D53+D55"
Range("D59").Value = Worksheets("Invulblad").Range("W59").Value
Else
If Range("D32").Value = "" Then
Range("D33
59").Value = ""
End If
End If
Greets & Thanks,
Gunti
JLatham said:
Not a stupid question, you know what you want to do and you've actually
written the code to do it. Now, the question to me is why you want to do it
in code rather than with a formula.
If you put this formula in L45 then it will get done without a macro:
=L43*Invulblad!AA47
The order doesn't matter, it could be =Invulblad!AA47 * L43
Excel will even do the work for you:
Click in L45 and type the = symbol
then click in cell L43
then type the * symbol
finally go to sheet Invulblad, click in cell AA47 and hit the [Enter] key
and Excel will have built the formula for you.
A note on sheet names - if your sheet name has a space in it, you need to
enclose it in single quote marks like: =L43 * 'Invul blad'!AA47
Hope this helps some. If you don't want to do it with the formula, let me
know and I'll provide some Worksheet_Change() event code to do the same thing.
Gunti said:
Hi,
I'm very new to creating macro's. I've got a (maybe stupid question).
I have the following situation:
Basiscly what i want (what i would make of it) is the following code:
Range("L45").Value = "Worksheets("Invulblad").Range("AA47").Value * L43"
I want cell L45 to say:
=0,05*L43
if AA47 on sheet 'Invulblad' is 0,05 and
=0,00*L43
if AA47 on sheet 'Invulblad' is 0,00
Any help appreciated,
Greets,
Gunti