PC Review


Reply
Thread Tools Rate Thread

Cell input to automatically divide itself

 
 
=?Utf-8?B?SmFz?=
Guest
Posts: n/a
 
      7th Sep 2007
Hi. I would like to know if it is possible to get the input of a cell to
automatically divide itself. So, if someone enters 4 in to A1, I would like
it to be divided by 2 and show the value 2 in the same input sell (A1).

Can this be done, and if it can, how?

Thanks in advance
Jas
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      7th Sep 2007
Use the worksheet_change event.

An overview of events
http://www.cpearson.com/excel/events.htm

--
Regards,
Tom Ogilvy


"Jas" wrote:

> Hi. I would like to know if it is possible to get the input of a cell to
> automatically divide itself. So, if someone enters 4 in to A1, I would like
> it to be divided by 2 and show the value 2 in the same input sell (A1).
>
> Can this be done, and if it can, how?
>
> Thanks in advance
> Jas

 
Reply With Quote
 
=?Utf-8?B?TWlrZSBI?=
Guest
Posts: n/a
 
      7th Sep 2007
hi,

Right click the sheet tab, view code and paste this in:-

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
If IsNumeric(Target) Then
Application.EnableEvents = False
Target.Value = (Target.Value / 2)
Application.EnableEvents = True
End If
End If
End Sub


Mike

"Jas" wrote:

> Hi. I would like to know if it is possible to get the input of a cell to
> automatically divide itself. So, if someone enters 4 in to A1, I would like
> it to be divided by 2 and show the value 2 in the same input sell (A1).
>
> Can this be done, and if it can, how?
>
> Thanks in advance
> Jas

 
Reply With Quote
 
=?Utf-8?B?SmFz?=
Guest
Posts: n/a
 
      7th Sep 2007
Thats brilliant - thank you so much - it works a treat!!!

"Mike H" wrote:

> hi,
>
> Right click the sheet tab, view code and paste this in:-
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
> If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
> If IsNumeric(Target) Then
> Application.EnableEvents = False
> Target.Value = (Target.Value / 2)
> Application.EnableEvents = True
> End If
> End If
> End Sub
>
>
> Mike
>
> "Jas" wrote:
>
> > Hi. I would like to know if it is possible to get the input of a cell to
> > automatically divide itself. So, if someone enters 4 in to A1, I would like
> > it to be divided by 2 and show the value 2 in the same input sell (A1).
> >
> > Can this be done, and if it can, how?
> >
> > Thanks in advance
> > Jas

 
Reply With Quote
 
=?Utf-8?B?SmltIFRob21saW5zb24=?=
Guest
Posts: n/a
 
      7th Sep 2007
You can do this without using macros by doing a little bit of slight of hand...

Assuming you are dealing with cell A1 on Sheet1... For Sheet 1 A1 make the
font colour the same as the background colour. Add the formula =Sheet1!A1/2
in cell A1 on Sheet 2. Select Tools -> Options -> View and uncheck Gridlines.
Now follow the oddity outlined here...

http://j-walk.com/ss/excel/odd/odd04.htm

I like this method because you do not need to enable macros and the original
value entered by the user is there in the cell (shows in the formula bar when
the cell is selected).
--
HTH...

Jim Thomlinson


"Jas" wrote:

> Hi. I would like to know if it is possible to get the input of a cell to
> automatically divide itself. So, if someone enters 4 in to A1, I would like
> it to be divided by 2 and show the value 2 in the same input sell (A1).
>
> Can this be done, and if it can, how?
>
> Thanks in advance
> Jas

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Sep 2007
right click sheet tab>view code>copy/paste this
As written, it works ONLY on column D

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 4 Then Exit Sub
Application.EnableEvents = False
Target = Target / 2
Application.EnableEvents = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Jas" <(E-Mail Removed)> wrote in message
news:7E0BE0A2-56D0-4EAE-9EF8-(E-Mail Removed)...
> Hi. I would like to know if it is possible to get the input of a cell to
> automatically divide itself. So, if someone enters 4 in to A1, I would
> like
> it to be divided by 2 and show the value 2 in the same input sell (A1).
>
> Can this be done, and if it can, how?
>
> Thanks in advance
> Jas


 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      7th Sep 2007
Just a heads up to the OP.
Since this doesn't check for errors and doesn't handle errors and attempts
to perform a math operation regardless of the value in the cell it would be
a poor implementation. Mike H does account for those problem.s

--
Regards,
Tom Ogilvy



"Don Guillett" wrote:

> right click sheet tab>view code>copy/paste this
> As written, it works ONLY on column D
>
> Private Sub Worksheet_Change(ByVal Target As Range)
> If Target.Column <> 4 Then Exit Sub
> Application.EnableEvents = False
> Target = Target / 2
> Application.EnableEvents = True
> End Sub
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Jas" <(E-Mail Removed)> wrote in message
> news:7E0BE0A2-56D0-4EAE-9EF8-(E-Mail Removed)...
> > Hi. I would like to know if it is possible to get the input of a cell to
> > automatically divide itself. So, if someone enters 4 in to A1, I would
> > like
> > it to be divided by 2 and show the value 2 in the same input sell (A1).
> >
> > Can this be done, and if it can, how?
> >
> > Thanks in advance
> > Jas

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Sep 2007
But it would do what the OP asked for.....

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Tom Ogilvy" <(E-Mail Removed)> wrote in message
news:FAC035FE-1689-4194-8784-(E-Mail Removed)...
> Just a heads up to the OP.
> Since this doesn't check for errors and doesn't handle errors and attempts
> to perform a math operation regardless of the value in the cell it would
> be
> a poor implementation. Mike H does account for those problem.s
>
> --
> Regards,
> Tom Ogilvy
>
>
>
> "Don Guillett" wrote:
>
>> right click sheet tab>view code>copy/paste this
>> As written, it works ONLY on column D
>>
>> Private Sub Worksheet_Change(ByVal Target As Range)
>> If Target.Column <> 4 Then Exit Sub
>> Application.EnableEvents = False
>> Target = Target / 2
>> Application.EnableEvents = True
>> End Sub
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Jas" <(E-Mail Removed)> wrote in message
>> news:7E0BE0A2-56D0-4EAE-9EF8-(E-Mail Removed)...
>> > Hi. I would like to know if it is possible to get the input of a cell
>> > to
>> > automatically divide itself. So, if someone enters 4 in to A1, I would
>> > like
>> > it to be divided by 2 and show the value 2 in the same input sell (A1).
>> >
>> > Can this be done, and if it can, how?
>> >
>> > Thanks in advance
>> > Jas

>>
>>


 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      7th Sep 2007
Since you are an MVP and you posted it well after a much superior solution
was posted, I think it is fair to advise the OP that it was ill conceived.
If he implements your solution, then gets an error and events are disabled
and he wonders what happened and so forth.

And Yes, at the lowest level, it answered his question - I don't think I
said otherwise.


--
Regards,
Tom Ogilvy




"Don Guillett" wrote:

> But it would do what the OP asked for.....
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> (E-Mail Removed)
> "Tom Ogilvy" <(E-Mail Removed)> wrote in message
> news:FAC035FE-1689-4194-8784-(E-Mail Removed)...
> > Just a heads up to the OP.
> > Since this doesn't check for errors and doesn't handle errors and attempts
> > to perform a math operation regardless of the value in the cell it would
> > be
> > a poor implementation. Mike H does account for those problem.s
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> >
> > "Don Guillett" wrote:
> >
> >> right click sheet tab>view code>copy/paste this
> >> As written, it works ONLY on column D
> >>
> >> Private Sub Worksheet_Change(ByVal Target As Range)
> >> If Target.Column <> 4 Then Exit Sub
> >> Application.EnableEvents = False
> >> Target = Target / 2
> >> Application.EnableEvents = True
> >> End Sub
> >>
> >> --
> >> Don Guillett
> >> Microsoft MVP Excel
> >> SalesAid Software
> >> (E-Mail Removed)
> >> "Jas" <(E-Mail Removed)> wrote in message
> >> news:7E0BE0A2-56D0-4EAE-9EF8-(E-Mail Removed)...
> >> > Hi. I would like to know if it is possible to get the input of a cell
> >> > to
> >> > automatically divide itself. So, if someone enters 4 in to A1, I would
> >> > like
> >> > it to be divided by 2 and show the value 2 in the same input sell (A1).
> >> >
> >> > Can this be done, and if it can, how?
> >> >
> >> > Thanks in advance
> >> > Jas
> >>
> >>

>
>

 
Reply With Quote
 
Don Guillett
Guest
Posts: n/a
 
      7th Sep 2007

Tom, As always you are correct. However, OP did not ask for more.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(E-Mail Removed)
"Tom Ogilvy" <(E-Mail Removed)> wrote in message
news:80D1876B-9E0C-4DBD-B2B8-(E-Mail Removed)...
> Since you are an MVP and you posted it well after a much superior solution
> was posted, I think it is fair to advise the OP that it was ill conceived.
> If he implements your solution, then gets an error and events are disabled
> and he wonders what happened and so forth.
>
> And Yes, at the lowest level, it answered his question - I don't think I
> said otherwise.
>
>
> --
> Regards,
> Tom Ogilvy
>
>
>
>
> "Don Guillett" wrote:
>
>> But it would do what the OP asked for.....
>>
>> --
>> Don Guillett
>> Microsoft MVP Excel
>> SalesAid Software
>> (E-Mail Removed)
>> "Tom Ogilvy" <(E-Mail Removed)> wrote in message
>> news:FAC035FE-1689-4194-8784-(E-Mail Removed)...
>> > Just a heads up to the OP.
>> > Since this doesn't check for errors and doesn't handle errors and
>> > attempts
>> > to perform a math operation regardless of the value in the cell it
>> > would
>> > be
>> > a poor implementation. Mike H does account for those problem.s
>> >
>> > --
>> > Regards,
>> > Tom Ogilvy
>> >
>> >
>> >
>> > "Don Guillett" wrote:
>> >
>> >> right click sheet tab>view code>copy/paste this
>> >> As written, it works ONLY on column D
>> >>
>> >> Private Sub Worksheet_Change(ByVal Target As Range)
>> >> If Target.Column <> 4 Then Exit Sub
>> >> Application.EnableEvents = False
>> >> Target = Target / 2
>> >> Application.EnableEvents = True
>> >> End Sub
>> >>
>> >> --
>> >> Don Guillett
>> >> Microsoft MVP Excel
>> >> SalesAid Software
>> >> (E-Mail Removed)
>> >> "Jas" <(E-Mail Removed)> wrote in message
>> >> news:7E0BE0A2-56D0-4EAE-9EF8-(E-Mail Removed)...
>> >> > Hi. I would like to know if it is possible to get the input of a
>> >> > cell
>> >> > to
>> >> > automatically divide itself. So, if someone enters 4 in to A1, I
>> >> > would
>> >> > like
>> >> > it to be divided by 2 and show the value 2 in the same input sell
>> >> > (A1).
>> >> >
>> >> > Can this be done, and if it can, how?
>> >> >
>> >> > Thanks in advance
>> >> > Jas
>> >>
>> >>

>>
>>


 
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
How to input pictures automatically based on cell input? bsharp Microsoft Excel Worksheet Functions 9 30th May 2009 07:16 AM
Numeric input in E to divide by 2 automatically in H Dale G Microsoft Excel Misc 3 14th Dec 2007 01:02 AM
Fill a spreadsheet automatically after one cell is input Justin Microsoft Excel Discussion 1 16th Jan 2007 03:00 AM
Re: trying to input number from another cell automatically RagDyeR Microsoft Excel Worksheet Functions 0 10th Aug 2004 04:33 PM
Automatically copy input from one cell to another picktr Microsoft Excel Discussion 2 26th Apr 2004 10:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 PM.