Replace comma with colon on input excel mask - excel

I have a cell in a column, where I enter values separated by coma (12,34). I must, to do it this way to be fast due to keyboard limitations.
But I need to replace the comma by a colon, preferably on the fly OR by using an input mask.
Is this possible?

Here is an example for data entry in column A.
Place the following event macro in the worksheet code area:
1. it will automatically run whenever you type changes to the worksheet
2. if you change a value in column A and the value contains a comma, that comma is automatically changed to a colon
Private Sub Worksheet_Change(ByVal Target As Range)
Dim RangeOfInterest As Range, Cell As Range, Intersection As Range
Set RangeOfInterest = Range("A:A")
Set Intersection = Intersect(Target, RangeOfInterest)
If Intersection Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each Cell In Intersection
v = Cell.Text
If InStr(v, ",") > 0 Then
Cell.NumberFormat = "#"
Cell.Value = Replace(v, ",", ":")
End If
Next Cell
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

Automatically delete the formula once I get the value in Excel?

Is that possible to do such a thing in excel?
I have been searching for many articles and videos
and all those are telling me to do it by hands
so, I wonder if there is any way to immediately delete the formula and keep the value? so that the links between the old and new value can be eliminated?
Like, I don't know, maybe =sum(A1:A5,del)
something like this?
Is there any way to immediately delete the formula and keep the value?
No
However, you can do so with vba. This is quite a simple code, which would check whether the value of ActiveSheet of Range("A1") is more than 0. If it is, it saves the cell as a value and the formula disappears. Just be careful, you cannot use "Undo" once you run the code:
Sub DeleteValue()
With ActiveSheet
If .Range("A1").Value2 <> 0 Then
.Range("A1").Value2 = .Range("A1").Value2
End If
End With
End Sub
Say, for example, we are entering items in column C. If we enter a formula in a C cell, we want the formula to be automatically converted to value. Enter the following event macro in the worksheet code area:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rInt As Range, r As Range, C As Range
Set C = Range("C:C")
Set rInt = Intersect(Target, C)
If rInt Is Nothing Then Exit Sub
Application.EnableEvents = False
For Each r In rInt
If r.HasFormula Then
r.Value = r.Value
End If
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!
Automatically? No.
Manually? Yes.
Select the cell range where you want to delete the formulas and keep only the values, copy them, then right click -> Paste Special -> Values (V).
This will replace the cell formulas with the cell values that the formula calculated (at the moment you copied them).

In excel how do i make cells in a column/row clickable?

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!

Function referring to the last entered cell in a column

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!

Create A popup InputBox from a cell and right the value to the next one

Hello this is my first question here and I'm new in VBA programming. I'm looking for a VBA code that would allows me when I select a cell on a range of cells to pop-up an input box to put some values.
For example when I select a cell from column B an input box pops up, requiring a value that goes to next cell in column C. That's because in the column B I have stored a formula (& the cell is locked) and I would not like to be deleted or changed by the user although I need his Input Value to be calculated by the formula, so I choose to store this value in a hidden cell next to it and make the reference into my formula.
How is this possible with VBA?
Thanks in advance,
Harris
This technique uses double click rather than single click. Your protection must allow the user to double click cells in column B
Enter the following Event macro in the worksheet code area:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Dim t As Range, B As Range
Set t = Target
Set B = Range("B:B")
If Intersect(t, B) Is Nothing Then Exit Sub
Cancel = True
t.Offset(0, 1).Value = Application.InputBox(Prompt:="Enter data value", Type:=1)
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!
I would suggest using the following Code:
Option Explicit
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Selection.Count = 1 Then
If Not Intersect(Target, Range("B:B")) Is Nothing Then
Cells(Target.Row, Target.Column + 1).Value = Application.InputBox("Insert your value please")
End If
End If
End Sub
This pops an inputbox up if you select any cell in column B and puts the value to the Cell in C. You have to put the Code directly into the particular Sheet in the VBA Window.

Make an excel cell mandatory, based on value of other 2 cells

So.. I've an excel where 2 consecutive cells can be marked with the same value (mostly Text), based on this 2 cells the value of the 3rd cell should be filled mandatorily by the user.
The range of cells can be different as I need to use the same snippet cross many excels.
Any help would be sincerely appreciated.
Many thanks! :)
There's more then one way to skin a cat, but probably the easiest way to do it would be to include a vba sub which (on some trigger, like submitting) checks the value of cell 1 and 2 and IF that value is whatever you want to trigger on... if cell 3 is blank prompt the user to fill in box three.
IF Range("A1").Value == "Trigger" And Range("A2").Value == "Trigger" And Range("A3") == "" Then msgBox("You must fill in cell A3")
If you add a break statement like End Sub, the sheet can't continue until that cell is filled.
This is an example for A1, B1, C1 enter the following event macro in the worksheet code area:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim A As Range, B As Range, C As Range
Set A = Range("A1")
Set B = Range("B1")
Set C = Range("C1")
If A <> "" And B <> "" And C = "" Then
Application.EnableEvents = False
C.Select
Application.EnableEvents = True
MsgBox "please enter a value in cell C1"
End If
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!

Resources