View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Simple Macro Question

Gunti,
Since your objective is to learn something about macros, I figured I'd show
you how to get this done with code. Both of these routines would need to go
into the worksheet's code module (get to it by right-clicking on the sheet's
name tab and choosing [View Code] from the list).

You'd need to automatically update the contents of L45 at 2 times: when the
sheet is activated (selected) so that any changes over in AA47 on Invulblad
get taken care of, and again in the sheet's _Change() event to take care of
times when someone changes the value of L43 while looking at it. So just
copy the code below and paste it into that code module:

Private Sub Worksheet_Activate()
'note that .Value is the default property,
'so we don't HAVE to mention it
Range("L45") = _
Worksheets("Invulblad").Range("AA47") * Range("L43")
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)
If Application.Intersect(Target, Range("L43")) _
Is Nothing Then
Exit Sub ' change was not in cell L43
End If
Range("L45") = _
Worksheets("Invulblad").Range("AA47") * Range("L43")
End Sub

"Gunti" wrote:

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