View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default After checked condition, add the data to adjacent cell automatically

Option Explicit

Sub demo()

manager "C"

End Sub

Sub manager(col As String)
Dim source As Range
Dim cell As Range

Set source = Columns(col).SpecialCells(xlCellTypeConstants)
If Not source Is Nothing Then
For Each cell In source.Cells
Select Case Len(cell.Value)
Case 10
cell.Offset(, 1).Value = 5
Case 20
cell.Offset(, 1).Value = 4
Case Else
End Select

Next

End If


End Sub


"tlee" wrote in message
...
Hi all,

Could anyone help me how to check condition, and fill the data to the
adjacent cell automatically?

Such that, there are several columns at the worksheet.

And I specified to use 2 columns (C and D) only.

Column D contains characters in each cell.
Column C is blank Column without data in all cell.

It checks the number of the characters in each cell of column D.
If the number of characters is 10 in D2, then fill "5" into C2
If the number of characters is 20 in D3, then fill "4" into C3

How can I implement that operation?

Thanks for your in advance.

TLee