Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 57
Default Check & Convert cell Value if condition auto

Hello,

Sheet 1, Column A is populated with Ref #s
I would macro to check value and alter (if) according to below:

LEN(VALUE) = 6 then "111"+VALUE
LEN(VALUE) = 7 then VALUE
VALUE already begins with "111" then VALUE

I believe an event macro in sheet is route.... that is as far as i can take
it.
Any help appreciated, I've searched for awhile but solution found not.

Thanks in advance.


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Check & Convert cell Value if condition auto

Hi,

Right click your sheet tab, view code and paste this in and run it

Sub sonic()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If Len(c) = 6 And Left(c.Value, 3) < 111 Then
c.Value = 111 & c.Value
End If
Next
End Sub

Mike

"SteveT" wrote:

Hello,

Sheet 1, Column A is populated with Ref #s
I would macro to check value and alter (if) according to below:

LEN(VALUE) = 6 then "111"+VALUE
LEN(VALUE) = 7 then VALUE
VALUE already begins with "111" then VALUE

I believe an event macro in sheet is route.... that is as far as i can take
it.
Any help appreciated, I've searched for awhile but solution found not.

Thanks in advance.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 57
Default Check & Convert cell Value if condition auto

Thanks Mike... Is there anyway to automatically run upon user exiting the
cell ?

BR, Steven



"Mike H" wrote:

Hi,

Right click your sheet tab, view code and paste this in and run it

Sub sonic()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If Len(c) = 6 And Left(c.Value, 3) < 111 Then
c.Value = 111 & c.Value
End If
Next
End Sub

Mike

"SteveT" wrote:

Hello,

Sheet 1, Column A is populated with Ref #s
I would macro to check value and alter (if) according to below:

LEN(VALUE) = 6 then "111"+VALUE
LEN(VALUE) = 7 then VALUE
VALUE already begins with "111" then VALUE

I believe an event macro in sheet is route.... that is as far as i can take
it.
Any help appreciated, I've searched for awhile but solution found not.

Thanks in advance.


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default Check & Convert cell Value if condition auto

Hi,

You could try this

Private Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("A:a")) Is Nothing Then
If Len(Target) = 6 And Left(Target.Value, 3) < 111 Then
Target.Value = 111 & Target.Value
End If
End If


Mike

"SteveT" wrote:

Thanks Mike... Is there anyway to automatically run upon user exiting the
cell ?

BR, Steven



"Mike H" wrote:

Hi,

Right click your sheet tab, view code and paste this in and run it

Sub sonic()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set myrange = Range("A1:A" & lastrow)
For Each c In myrange
If Len(c) = 6 And Left(c.Value, 3) < 111 Then
c.Value = 111 & c.Value
End If
Next
End Sub

Mike

"SteveT" wrote:

Hello,

Sheet 1, Column A is populated with Ref #s
I would macro to check value and alter (if) according to below:

LEN(VALUE) = 6 then "111"+VALUE
LEN(VALUE) = 7 then VALUE
VALUE already begins with "111" then VALUE

I believe an event macro in sheet is route.... that is as far as i can take
it.
Any help appreciated, I've searched for awhile but solution found not.

Thanks in advance.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
auto filter with condition RKS Excel Discussion (Misc queries) 1 October 25th 07 08:11 AM
Display in same cell lbs(kgs) using formula to auto-convert lbs Ian Burnby New Users to Excel 1 March 2nd 07 11:43 PM
auto change cell text colour resulting from a condition Chinaman Excel Worksheet Functions 2 December 14th 06 01:19 AM
Continually check if condition is true in VBA [email protected] Excel Discussion (Misc queries) 1 October 4th 06 05:43 PM


All times are GMT +1. The time now is 09:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"