Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Tim
 
Posts: n/a
Default delete a cell if it contains specific word

Im trying to write a formula were i can get the programe to check the file
and if a cell contains 'agency' i want it to delete the cell and shift it
left. the reason for the formula is that the file will be in a differnt
order/size each time, and cannot just do this manually.

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.misc
Gary''s Student
 
Posts: n/a
Default delete a cell if it contains specific word

Enter and run this macro:

Sub Macro1()
Dim i, j As Long
Dim s, ss As String
ss = "agency"
For i = 10 To 1 Step -1
For j = 10 To 1 Step -1
s = Cells(j, i).Value
If Not (InStr(s, ss) = 0) Then
Cells(j, i).Delete Shift:=xlToLeft
End If
Next
Next
End Sub


As coded it covers 10 rows by 10 columns. Expand it to suit your needs.
--
Gary's Student


"Tim" wrote:

Im trying to write a formula were i can get the programe to check the file
and if a cell contains 'agency' i want it to delete the cell and shift it
left. the reason for the formula is that the file will be in a differnt
order/size each time, and cannot just do this manually.

Thanks

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
show name when a cell has specific word Noemi Excel Discussion (Misc queries) 1 October 24th 05 09:29 AM
Pasting Word table cell with paragraph markers into single Excel c Steve Excel Discussion (Misc queries) 1 June 16th 05 11:26 PM
Automatically Put a Value in a specific cell. Shawn Excel Discussion (Misc queries) 2 May 23rd 05 09:05 PM
how do I highlite text within a cell (specific characters) tim Excel Discussion (Misc queries) 1 May 20th 05 05:23 AM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM


All times are GMT +1. The time now is 03:26 PM.

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"