Solved

format calculator in same cell

Posted on 2014-04-29
7
154 Views
Last Modified: 2014-05-15
Is there anyway in excel, if a user enters a value in a cell, i.e. 4, it automatically performs a calculation to change that value. For example in A1, if a user types 4, in cell B1 I have the value 4 pre-populated, so I want A1 to show the output of the formula

A1*B1,

so if the user types 4, it will return 16. I cant see anyway to do this via formatting.
0
Comment
Question by:pma111
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 40029170
Hi,

Why don't you want the result in another cell?

Regards
0
 
LVL 15

Expert Comment

by:Vikas Garg
ID: 40029178
Hello,

I don't think so that the same can be done.

So Rethink on it....
0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40029195
Put this code in the worksheet module:
Private Sub Worksheet_Change(ByVal Target As Range)
    Target.Value = Target.Value * Target.Offset(, 1).Value
End Sub

Open in new window

0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
LVL 52

Expert Comment

by:Rgonzo1971
ID: 40029207
Hi,

Of course it is possible to make it but it is bad design to have input and result at the same place
Say your are tipping 12 answer a call and do not remember what you tipped you won't know whether 12 is the input or the result.

Regards
0
 
LVL 27

Accepted Solution

by:
MacroShadow earned 250 total points
ID: 40029216
Sorry, this is the code you need:
Dim blnFlag As Boolean

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
        If Not blnFlag Then
            blnFlag = True
            Target.Value = CLng(Target.Value) * CLng(Target.Offset(, 1).Value)
        End If
    End If
    blnFlag = False
End Sub

Open in new window

0
 
LVL 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
ID: 40029245
@MacroShadow

Wouldn't be easier to disable the events instaed of a flag

Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
    If Not Intersect(Target, Range("A1")) Is Nothing Then
        Target.Value = Target.Value * Target.Offset(, 1).Value
    End If
Application.EnableEvents = True
End Sub

Open in new window

0
 
LVL 27

Expert Comment

by:MacroShadow
ID: 40029256
Yes it would. Although personally I wouldn't recommend it without thoroughly examining the workflow.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a serious pitfall that can happen when deleting shapes using VBA.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question