Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro searches for keyword. If found , puts 0 in cell from next co

Example

A1 : available in 10 days ...
A2 : unavailable
A3 : available in 4 days
A4 : unavailable

B1 : 10.30
B2 : 5.30
B3 : 13.89
B4 : 5.48

Tha macro should search for "unavailable" . It finds the keyword in A2 and
A4 . So , it changes content from the B2 and B4 cells to 0

B1 : 10.30
B2 : 0
B3 : 13.89
B4 : 0
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Macro searches for keyword. If found , puts 0 in cell from next co

Hi,

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

Sub stance()
lastrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set MyRange = Range("A1:A" & lastrow)
For Each c In MyRange
If UCase(c.Value) = "UNAVAILABLE" Then
c.Offset(, 1) = 0
End If
Next
End Sub

Mike

"andrei" wrote:

Example

A1 : available in 10 days ...
A2 : unavailable
A3 : available in 4 days
A4 : unavailable

B1 : 10.30
B2 : 5.30
B3 : 13.89
B4 : 5.48

Tha macro should search for "unavailable" . It finds the keyword in A2 and
A4 . So , it changes content from the B2 and B4 cells to 0

B1 : 10.30
B2 : 0
B3 : 13.89
B4 : 0

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Macro searches for keyword. If found , puts 0 in cell from next co

Sub ReFormat()
For Each c In Range("A1:A" & Cells(Cells.Rows.Count, "A").End(xlUp).Row)
If InStr(1, c.Text, "UnAvailable", vbTextCompare) Then c.Offset(, 1) = 0
Next
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"andrei" wrote:

Example

A1 : available in 10 days ...
A2 : unavailable
A3 : available in 4 days
A4 : unavailable

B1 : 10.30
B2 : 5.30
B3 : 13.89
B4 : 5.48

Tha macro should search for "unavailable" . It finds the keyword in A2 and
A4 . So , it changes content from the B2 and B4 cells to 0

B1 : 10.30
B2 : 0
B3 : 13.89
B4 : 0

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default Macro searches for keyword. If found , puts 0 in cell from nex

Many thanks . Both macro works


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
macro which delets cell if the cell above has the same keyword andrei Excel Programming 2 September 29th 09 07:46 AM
Macro which searches for a character . When found delets what's be andrei Excel Programming 4 September 28th 09 06:09 PM
Populate a cell based on a keyword it found in another ghobbit Excel Programming 12 May 16th 06 04:47 AM
Populate a cell based on a keyword it found in another ghobbit[_2_] Excel Programming 0 May 11th 06 06:45 PM
Need help -- a Macro that searches for string in a cell range? graphicGuy Excel Programming 1 April 18th 06 05:53 PM


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