View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Macro puts text if keyword is found in cell above

Sub findthings()
whatword = InputBox("Enter a Word")
With ActiveSheet.Columns(1)
Set c = .Find(whatword, LookIn:=xlValues, lookat:=xlPart)
If Not c Is Nothing Then
FirstAddress = c.Address
Do
With c.Offset(1, 0)
If .Value = "" Then
.Value = "No Description"
End If
End With
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With
End Sub


Gord Dibben MS Excel MVP

On Tue, 11 May 2010 16:34:24 +0100, andrei
wrote:


I have a sheet . in A column i have cells with text , and empty cells .
I want the macro to search the column for given keyword . If found , to
go to next cell in A column . If that cell in empty , it should put "No
description" . If that cell is not empty , it should leave it as it is .
Example :

keyword : mother

A1: mother goes home
A2: house
A3: empty
A4: my mother is ...
A5: empty

So , A5 should become : "No description"

Thanks !