ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Automating entry in a cell (https://www.excelbanter.com/excel-worksheet-functions/104541-automating-entry-cell.html)

BrownsFan

Automating entry in a cell
 
I am trying to automate entry in a cell, in which the first digit will
always be the same value, such as "X", followed by a 6 digit number to
be entered. What I envision is that each cell in this column will have
the "X" value hardcoded in the first position so that entry of the 6
digit number can begin at the second position when the user selects the
cell. Another possibility would be for the user to enter the 6 digit
number and the "X" populate the cell in the first position when the
user exits the cell.

Is either of these feasible, and what would be the best way to
accomplish?

I appreciate any help!


RagDyeR

Automating entry in a cell
 
You could try a custom format of:

"X"#

--

HTH,

RD
================================================== ===
Please keep all correspondence within the Group, so all may benefit!
================================================== ===


"BrownsFan" wrote in message
ups.com...
I am trying to automate entry in a cell, in which the first digit will
always be the same value, such as "X", followed by a 6 digit number to
be entered. What I envision is that each cell in this column will have
the "X" value hardcoded in the first position so that entry of the 6
digit number can begin at the second position when the user selects the
cell. Another possibility would be for the user to enter the 6 digit
number and the "X" populate the cell in the first position when the
user exits the cell.

Is either of these feasible, and what would be the best way to
accomplish?

I appreciate any help!



Ken Johnson

Automating entry in a cell
 
Hi,

This Worksheet_Change Event procedure adds 5000000 to any number
entered into column C. You could edit the code to suit your needs...

Private Sub Worksheet_Change(ByVal Target As Range)
'Change "C:C" to suit you needs
If Not Intersect(Target, Range("C:C")) Is Nothing Then
Dim rngCell As Range
For Each rngCell In Target
On Error Resume Next
Application.EnableEvents = False
'Change 5000000 to suit your needs
rngCell.Value = rngCell.Value + 5000000
Application.EnableEvents = True
Next rngCell
End If
End Sub

Paste the code into the worksheet's code module in the Visual Basic
Editor by right clicking the sheet tab, selecting "View Code" from the
popup menu then paste the copied code. Press Alt + F11 to return to
Excel.

If your Security level is higher than medium then go
Tools|Macro|Security... select Medium|OK|Close the workbook|ReOpen the
workbook|Select "Enable Macros" on the "Security Warning" dialog

Ken Johnson



All times are GMT +1. The time now is 04:45 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com