Solved

format calculator in same cell

Posted on 2014-04-29
7
149 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
  • 3
  • 3
7 Comments
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
Hi,

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

Regards
0
 
LVL 14

Expert Comment

by:Vikas Garg
Comment Utility
Hello,

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

So Rethink on it....
0
 
LVL 26

Expert Comment

by:MacroShadow
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
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 26

Accepted Solution

by:
MacroShadow earned 250 total points
Comment Utility
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 48

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 250 total points
Comment Utility
@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 26

Expert Comment

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

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now