View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.misc
Gunti Gunti is offline
external usenet poster
 
Posts: 58
Default Simple Macro Question

Now i'm getting completely confused haha. I actually meant it to show
'0,05*D53*

"Gunti" wrote:

Thanks alot for explaining this, even though it still isn't what i'm looking
for. I'm learning alot from looking at other people's code.

The thing is that i've come as far as what code you gave me.

Range("D55").Value = (Range("D53").Value /
Worksheets("Invulblad").Range("AA51")) - Range("D53").Value

If D53 = 50
and AA51 = 0,05
doesn't actually show '0,05*50'

It however shows 2,5.



"JLatham" wrote:

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