#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default validation

hi
i have column containing name of the customer
i want to change pattern of each cell to 'red'
if a cell contains charters like !,@,#,$,%,^,&,*,-,_,+,= or space
how to achieve this task?
please help
--
hemu
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default validation

Hi Hemant,


i have column containing name of the customer
i want to change pattern of each cell to 'red'
if a cell contains charters like !,@,#,$,%,^,&,*,-,_,+,= or space
how to achieve this task?


Try:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim rng2 As Range
Dim rCell As Range
Dim sStr As String
Dim i As Long

Set Rng = Range("E1:E200") '<<=== CHANGE
Set rng2 = Intersect(Rng, Target)

If Not rng2 Is Nothing Then
For Each rCell In rng2.Cells
With rCell
For i = 1 To Len(.Value)
sStr = Mid(.Value, i, 1)
If Not IsNumeric(sStr) And Asc(sStr) < 65 Then
.Interior.ColorIndex = 3
Else
.Interior.ColorIndex = xlNone
End If
Next i
End With
Next rCell
End If

End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default validation

thanks norman
i will let u know immidiately
stay on
--
hemu


"Norman Jones" wrote:

Hi Hemant,


i have column containing name of the customer
i want to change pattern of each cell to 'red'
if a cell contains charters like !,@,#,$,%,^,&,*,-,_,+,= or space
how to achieve this task?


Try:

'=============
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
Dim rng2 As Range
Dim rCell As Range
Dim sStr As String
Dim i As Long

Set Rng = Range("E1:E200") '<<=== CHANGE
Set rng2 = Intersect(Rng, Target)

If Not rng2 Is Nothing Then
For Each rCell In rng2.Cells
With rCell
For i = 1 To Len(.Value)
sStr = Mid(.Value, i, 1)
If Not IsNumeric(sStr) And Asc(sStr) < 65 Then
.Interior.ColorIndex = 3
Else
.Interior.ColorIndex = xlNone
End If
Next i
End With
Next rCell
End If

End Sub
'<<=============

This is worksheet event code and should be pasted into the worksheets's code
module (not a standard module and not the workbook's ThisWorkbook module):

Right-click the worksheet's tab
Select 'View Code' from the menu and paste the code.
Alt-F11 to return to Excel.


---
Regards,
Norman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default validation

thanks
it worked
--
hemu


"Hemant_india" wrote:

hi
i have column containing name of the customer
i want to change pattern of each cell to 'red'
if a cell contains charters like !,@,#,$,%,^,&,*,-,_,+,= or space
how to achieve this task?
please help
--
hemu

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
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
data validation invalid in dynamic validation list ilia Excel Discussion (Misc queries) 0 November 7th 06 12:54 PM
Validation (Drop down list vs simple text length validation) Bob Phillips[_6_] Excel Programming 2 April 27th 04 07:47 PM
Validation (Drop down list vs simple text length validation) Jason Morin[_2_] Excel Programming 1 April 27th 04 04:56 PM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


All times are GMT +1. The time now is 03:19 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"