Microsoft Office Forums


Reply
Thread Tools Display Modes

Update cell using vba

 
 
Pete Provencher
Guest
Posts: n/a
 
      03-26-2007, 12:45 PM
Using Excel 2003:

What I would like to do is type a number into a cell and then when I hit
enter I would like vba to update that number through a formula. I know I
could just add another column but if possible I would like to do it the way
mentioned.

Pete Provencher


 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      03-26-2007, 12:54 PM
I'd use the other cell--just because it might make it easier to update the cell
when I make a typing change.

But if you want, rightclick on the worksheet tab that should behave this way.
Select View Code and paste this into the code window:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub

On Error GoTo ErrHandler:

If IsNumeric(Target.Value) = False Then
Exit Sub
End If

Application.EnableEvents = False
Target.Value = Target.Value * 2 + 3 + Target.Value ^ 4

ErrHandler:
Application.EnableEvents = True

End Sub

I check column A -- you may want to change this.

And I bet my formula isn't what you wanted.

Pete Provencher wrote:
>
> Using Excel 2003:
>
> What I would like to do is type a number into a cell and then when I hit
> enter I would like vba to update that number through a formula. I know I
> could just add another column but if possible I would like to do it the way
> mentioned.
>
> Pete Provencher


--

Dave Peterson
 
Reply With Quote
 
 
 
 
Pete Provencher
Guest
Posts: n/a
 
      03-26-2007, 03:32 PM
Thanks. It worked for what I needed.

Pete Provencher
"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'd use the other cell--just because it might make it easier to update the
> cell
> when I make a typing change.
>
> But if you want, rightclick on the worksheet tab that should behave this
> way.
> Select View Code and paste this into the code window:
>
> Option Explicit
> Private Sub Worksheet_Change(ByVal Target As Range)
>
> If Target.Cells.Count > 1 Then Exit Sub
> If Intersect(Target, Me.Range("a:a")) Is Nothing Then Exit Sub
>
> On Error GoTo ErrHandler:
>
> If IsNumeric(Target.Value) = False Then
> Exit Sub
> End If
>
> Application.EnableEvents = False
> Target.Value = Target.Value * 2 + 3 + Target.Value ^ 4
>
> ErrHandler:
> Application.EnableEvents = True
>
> End Sub
>
> I check column A -- you may want to change this.
>
> And I bet my formula isn't what you wanted.
>
> Pete Provencher wrote:
>>
>> Using Excel 2003:
>>
>> What I would like to do is type a number into a cell and then when I hit
>> enter I would like vba to update that number through a formula. I know I
>> could just add another column but if possible I would like to do it the
>> way
>> mentioned.
>>
>> Pete Provencher

>
> --
>
> Dave Peterson



 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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
Using Excel VB, Update a specific cell, on any change of anotherspecific cell Paul Excel Misc 2 03-28-2013 12:49 PM
Cell naming using cell references (VBA? Offset?) StephenT Excel Misc 2 06-24-2009 06:06 PM
HELP W/ VBA: SELECT RANGE, ALLCAPS, CELL COLOR, RETURN TO BLANK CELL/PATTERN CELL extremejobtvshow@gmail.com Excel Programming 5 06-28-2008 06:49 PM
NEED VBA TO SELECT A CELL; NOTE THE CELL VALUE;COPYADJ CELL;FIND CELL VALUE IN A RANGE AND SO ON CAPTGNVR Excel Programming 2 07-08-2007 03:18 PM
using vba to update vba form jrh Excel Programming 3 09-23-2003 10:11 PM


All times are GMT. The time now is 02:41 PM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.


Welcome!
Welcome to the Microsoft Office Forums
 


Latest Threads
Mail Merging Content With High Quality
oleander (04-17-2014, 11:59 PM)

Aargh. What is this?
PeteJ (04-17-2014, 12:10 PM)

Word 2013 Insert Symbol (Not Responding)
tpthrshr (04-17-2014, 02:49 AM)

Can't save a large Word document
Josh (04-17-2014, 01:03 AM)

Remote help?
newman200 (04-13-2014, 12:54 PM)