PC Review


Reply
Thread Tools Rate Thread

circular argument

 
 
Joanne
Guest
Posts: n/a
 
      10th Feb 2008
I am trying to make a formula in a cell that will read the value the
user puts in the cell and multiply it by 40, giving me that as the cell
value instead of just the input.
I tried putting this in the cell
=d15*40 (in cell d15)
This gives me a circular argument error.
I suspect I might need to do it in vba, but where does it go in the vba.
I am still confused by the Change event on the worksheet and what all
goes there and how to line up the sequence of events. Oh my!
Thanks for any info you can give me
Joanne
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      10th Feb 2008
One way is to right click the sheet tab, view code and paste this in. It
works on cell A1 but If you want to apply this to a range of cells and don't
know how to modify it then post back.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Address = "$A$1" Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target = Target * 40
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike

"Joanne" wrote:

> I am trying to make a formula in a cell that will read the value the
> user puts in the cell and multiply it by 40, giving me that as the cell
> value instead of just the input.
> I tried putting this in the cell
> =d15*40 (in cell d15)
> This gives me a circular argument error.
> I suspect I might need to do it in vba, but where does it go in the vba.
> I am still confused by the Change event on the worksheet and what all
> goes there and how to line up the sequence of events. Oh my!
> Thanks for any info you can give me
> Joanne
>

 
Reply With Quote
 
Joanne
Guest
Posts: n/a
 
      10th Feb 2008
THank you Mike
Yes I need it to run on a range of col d cells. Can I name the range and
use it in the code like this?
If Target.Address = RangeName Then

So this goes in the worksheet_change event. How does the excel ws know
in what order to run all the little snippets of coding that are in the
worksheet_change event? I guess I am a bit hung up on getting the code
in proper sequence so that it will run - it seems to this newbie that
that is not necessary in the change event? Am I correct?

Thanks for your help
Joanne

Mike H wrote:

> One way is to right click the sheet tab, view code and paste this in. It
> works on cell A1 but If you want to apply this to a range of cells and don't
> know how to modify it then post back.
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> If Target.Address = "$A$1" Then
> If IsNumeric(Target) Then
> On Error Resume Next
> Application.EnableEvents = False
> Target = Target * 40
> Application.EnableEvents = True
> On Error GoTo 0
> End If
> End If
> End Sub
>
> Mike
>
> "Joanne" wrote:
>
> > I am trying to make a formula in a cell that will read the value the
> > user puts in the cell and multiply it by 40, giving me that as the cell
> > value instead of just the input.
> > I tried putting this in the cell
> > =d15*40 (in cell d15)
> > This gives me a circular argument error.
> > I suspect I might need to do it in vba, but where does it go in the vba.
> > I am still confused by the Change event on the worksheet and what all
> > goes there and how to line up the sequence of events. Oh my!
> > Thanks for any info you can give me
> > Joanne
> >


 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      10th Feb 2008
Joanne,

No you do it like this

If Not Intersect(Target, Range("D1100")) Is Nothing Then

You can extend or shorten the range as you require but this works on D1 - D100

I'm not quite sure what you mean by the second part of your question but
this may help.

Events happen whenever change is made in a worksheet/book and there are
several worksheet ones:-
Activate
Before double click
Change
etc

With regard to the worksheet change event it is fired every time the
worksheet changes and if there is any code in the event module then it is
executed. In our case when any cell is changed the event fires but the code
only does anything if it's the cells specified within the code that have
changed.

Have a look here where events are explained far better then I do.
http://www.cpearson.com/excel/Events.aspx

Mike

"Joanne" wrote:

> THank you Mike
> Yes I need it to run on a range of col d cells. Can I name the range and
> use it in the code like this?
> If Target.Address = RangeName Then
>
> So this goes in the worksheet_change event. How does the excel ws know
> in what order to run all the little snippets of coding that are in the
> worksheet_change event? I guess I am a bit hung up on getting the code
> in proper sequence so that it will run - it seems to this newbie that
> that is not necessary in the change event? Am I correct?
>
> Thanks for your help
> Joanne
>
> Mike H wrote:
>
> > One way is to right click the sheet tab, view code and paste this in. It
> > works on cell A1 but If you want to apply this to a range of cells and don't
> > know how to modify it then post back.
> >
> > Private Sub Worksheet_Change(ByVal Target As Range)
> > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > If Target.Address = "$A$1" Then
> > If IsNumeric(Target) Then
> > On Error Resume Next
> > Application.EnableEvents = False
> > Target = Target * 40
> > Application.EnableEvents = True
> > On Error GoTo 0
> > End If
> > End If
> > End Sub
> >
> > Mike
> >
> > "Joanne" wrote:
> >
> > > I am trying to make a formula in a cell that will read the value the
> > > user puts in the cell and multiply it by 40, giving me that as the cell
> > > value instead of just the input.
> > > I tried putting this in the cell
> > > =d15*40 (in cell d15)
> > > This gives me a circular argument error.
> > > I suspect I might need to do it in vba, but where does it go in the vba.
> > > I am still confused by the Change event on the worksheet and what all
> > > goes there and how to line up the sequence of events. Oh my!
> > > Thanks for any info you can give me
> > > Joanne
> > >

>
>

 
Reply With Quote
 
Joanne
Guest
Posts: n/a
 
      10th Feb 2008
Thanks again Mike - you solved my immediate problem and given me some
understanding of the change event. I will follow the link and learn more
so I can better help myself.
Joanne
Mike H wrote:

> Joanne,
>
> No you do it like this
>
> If Not Intersect(Target, Range("D1100")) Is Nothing Then
>
> You can extend or shorten the range as you require but this works on D1 - D100
>
> I'm not quite sure what you mean by the second part of your question but
> this may help.
>
> Events happen whenever change is made in a worksheet/book and there are
> several worksheet ones:-
> Activate
> Before double click
> Change
> etc
>
> With regard to the worksheet change event it is fired every time the
> worksheet changes and if there is any code in the event module then it is
> executed. In our case when any cell is changed the event fires but the code
> only does anything if it's the cells specified within the code that have
> changed.
>
> Have a look here where events are explained far better then I do.
> http://www.cpearson.com/excel/Events.aspx
>
> Mike
>
> "Joanne" wrote:
>
> > THank you Mike
> > Yes I need it to run on a range of col d cells. Can I name the range and
> > use it in the code like this?
> > If Target.Address = RangeName Then
> >
> > So this goes in the worksheet_change event. How does the excel ws know
> > in what order to run all the little snippets of coding that are in the
> > worksheet_change event? I guess I am a bit hung up on getting the code
> > in proper sequence so that it will run - it seems to this newbie that
> > that is not necessary in the change event? Am I correct?
> >
> > Thanks for your help
> > Joanne
> >
> > Mike H wrote:
> >
> > > One way is to right click the sheet tab, view code and paste this in. It
> > > works on cell A1 but If you want to apply this to a range of cells and don't
> > > know how to modify it then post back.
> > >
> > > Private Sub Worksheet_Change(ByVal Target As Range)
> > > If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> > > If Target.Address = "$A$1" Then
> > > If IsNumeric(Target) Then
> > > On Error Resume Next
> > > Application.EnableEvents = False
> > > Target = Target * 40
> > > Application.EnableEvents = True
> > > On Error GoTo 0
> > > End If
> > > End If
> > > End Sub
> > >
> > > Mike
> > >
> > > "Joanne" wrote:
> > >
> > > > I am trying to make a formula in a cell that will read the value the
> > > > user puts in the cell and multiply it by 40, giving me that as the cell
> > > > value instead of just the input.
> > > > I tried putting this in the cell
> > > > =d15*40 (in cell d15)
> > > > This gives me a circular argument error.
> > > > I suspect I might need to do it in vba, but where does it go in the vba.
> > > > I am still confused by the Change event on the worksheet and what all
> > > > goes there and how to line up the sequence of events. Oh my!
> > > > Thanks for any info you can give me
> > > > Joanne
> > > >

> >
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Circular or semi-circular chart DKS Microsoft Excel Charting 3 3rd Nov 2009 01:50 PM
Throwing Argument exception when method argument is a Guid Andy B Microsoft VB .NET 2 11th Jan 2009 06:38 PM
Function (array argument, range argument, string argument) vba Witek Microsoft Excel Programming 3 24th Apr 2005 03:12 PM
Circular Argument calv1n Microsoft Excel Discussion 3 23rd Aug 2004 10:38 PM
How to overcome the limitation: Cannot pass 'argument' as ref or out, because ' argument ' is a marshal-by-reference class Mountain Bikn' Guy Microsoft C# .NET 2 15th Nov 2003 07:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:56 PM.