It might be a strange question, but is it possible to use a formula that changes the original cell's value to the outcome of that formula?
for example: I fill in C5 "10", and I inserted a formula there that multiplies it by 5, so the value in C5 will change to "50"
of course it mustn't make a loop, multiplying every new value by 5 so the cell will soon be too small for the number. (10)*5)*5)*5)*5)*5....
only once.
I hope this is possible although I don't think so.
Cheers,
Bart.
Say we enter values in cell C5 and want to have the value automatically multiplied by 5 each time we enter a new value.
Place the following Event Macro in the worksheet code area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim C5 As Range
Set C5 = Range("C5")
If Intersect(Target, C5) Is Nothing Then Exit Sub
Application.EnableEvents = False
C5 = 5 * C5
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
Related
I have cell with number A1, how create another cell (A2) with highest number of A1?
For example: A1 = 10 A2 = 10, then i change A1 to 20 A2 = 20, then i change A1 = 12 but A2 still 20.
It means if A1 greater than previous A1 it should be write to A2
Place the following event macro in the worksheet code area:
Private Sub Worksheet_Calculate()
newval = Range("A1")
If Range("A2") = "" Then
Else
If newval <= Range("A2") Then Exit Sub
End If
Application.EnableEvents = False
Range("A2") = newval
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
You can absolutely do that. The number you want to save is in cell A1. Place this formula in cell A2 intentionally creating a circular reference.
=IF(A1>A2,A1,A2)
You need to enable iterative calculation in File > Options > Formulas > Enable iterative calculation.
Anytime a number in A1 is higher, it will save that number. It will ignore numbers with lower value. It even saves the number when saved and reopened.
See the example of a timestamp using a circular reference.
I would like to put a value to A1 and when I changed A1 I want to keep the first entered value in another cell.
Would that be possible ?
Thanks
Insert the following event macro in the worksheet area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, N As Long
Set A = Range("A1")
If Intersect(Target, A) Is Nothing Then Exit Sub
If Cells(1, 2).Value = "" Then
N = 1
Else
N = Cells(1, 2).End(xlUp).Row + 1
End If
Application.EnableEvents = False
A.Copy Cells(N, "B")
Application.EnableEvents = True
End Sub
Every time you enter a value in A1, that value will be recorded in the first availab1e cell in column B
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
Here is a solution using formulas, only. It requires that you switch the iterative calculations on in Excel options.
You can set it to 1 iteration.
You only need to enter the following formula into B1:
=IF(ISBLANK(C1),IF(ISBLANK(A1),B1,IF(B1="",A1,B1)),"")
A1 is the cell whose value is to be remembered, B1 is the memory location, C1 is the reset button.
As long as C1 is empty, B1 holds the very first value entered into
A1.
When you enter any value in C1, B1 becomes empty and blocked in
this state.
You can then delete the content of C1, and B1 will become responsive again. It will "catch" the first value present A1 and keep it until you reset it again.
In excel how do i make cells in a column/row clickable?
I have a data grid and want to be able to click on a cell in column N and have that data in that cell appear in another cell.
I also want to be able to click on a cell in row 3 and have that data appear in a second cell.
(Table begins at column N and row 3)
Here is a method for double click
Enter the following event macro in the worksheet code area:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim Reg As Range, B2 As Range
Set Reg = Union(Cells(1, 1).EntireRow, Cells(1, 1).EntireColumn).Cells
Set B2 = Range("B2")
If Intersect(Target, Reg) Is Nothing Then Exit Sub
Cancel = True
B2.Value = Target.Value
End Sub
If you double click on a cell in column A or row#1, its value will appear in cell B2
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
I want a function that refers to the last entered cell in a particular column. For example, consider column A and the entries are as follows.
1st entry in column is in cell A1,
2nd in A2, 3rd in A5, 4th in A8, 5th in A7.
Now i want a function that refers to the cell A7.
With data in column A use
=LOOKUP(2,1/(A:A>0),A:A)
For example:
Will display Albert
Here is the macro approach. The macro monitors changes made to column A and records the last value in cell B1
Insert this event macro in the worksheet code area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim A As Range, B As Range
Set A = Range("A:A")
Set B = Range("B1")
If Intersect(A, Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
B = Target.Value
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!
For example, I have cell A1 in sheet 1 and its value is "yes". If I fill in the cell A1 in sheet2 ='sheet1'!A1 then we know what is going on. However, how can I make the cell A2 in sheet2 also have "yes" when I fill in cell A2 of sheet1 without filling in cell A2 of sheet2 ='sheet1'!A2 ?
In other word, I want to make excel automatically fill a cell of sheet2 each time when I fill a value in corresponding cell of sheet1.
Enter the following event macro in the Sheet1 code area:
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
Dim r As Range
For Each r In Target
addy = r.Address
Sheets("Sheet2").Range(addy).Value = r.Value
Next r
Application.EnableEvents = True
End Sub
Because it is worksheet code, it is very easy to install and automatic to use:
right-click the tab name near the bottom of the Excel window
select View Code - this brings up a VBE window
paste the stuff in and close the VBE window
If you have any concerns, first try it on a trial worksheet.
If you save the workbook, the macro will be saved with it.
If you are using a version of Excel later then 2003, you must save
the file as .xlsm rather than .xlsx
To remove the macro:
bring up the VBE windows as above
clear the code out
close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
and
http://msdn.microsoft.com/en-us/library/ee814735(v=office.14).aspx
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
Macros must be enabled for this to work!