Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default search for absense of data


I am working with a spreadsheet that is being used primarily as
database with several elements of alphanumeric data in each cell.
need to search for cells that are missing an element “(3-2)” and the
search for something else “P POS” within the cell, replace it wit
something, and continue checking the remaining cells. If a cell ha
“(3-2)” in it I need to bypass the cell.

I cannot just search for “P POS” because it needs to remain in th
cells that contain (3-2).

For starters, I cannot seem to figure out how to find the absence o
something…

Thanks in advance
Rober

--
Hammer_75
-----------------------------------------------------------------------
Hammer_757's Profile: http://www.excelforum.com/member.php...nfo&userid=741
View this thread: http://www.excelforum.com/showthread.php?threadid=31399

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default search for absense of data

Maybe just looking through the cells would be enough:

Option Explicit
Sub testme()

Dim myRng As Range
Dim myCell As Range
Dim Str3_2 As String
Dim StrP_POS As String
Dim P_POS_StartsAt As Long
Dim NewString As String

Str3_2 = "(3-2)"
StrP_POS = "P POS"
NewString = "hi there"

With ActiveSheet
Set myRng = Nothing
On Error Resume Next
Set myRng = .Range("a1", .Cells(.Rows.Count, "A").End(xlUp)) _
.Cells.SpecialCells(xlTextValues)

'whole sheet???
'Set myRng = .UsedRange.Cells.SpecialCells(xlTextValues)

On Error GoTo 0
For Each myCell In myRng.Cells
If InStr(1, myCell.Value, Str3_2, vbTextCompare) 0 Then
'it's in there
'do nothing
Else
P_POS_StartsAt = InStr(1, myCell.Value, StrP_POS, vbTextCompare)
If P_POS_StartsAt 0 Then
myCell.Value = Left(myCell.Value, P_POS_StartsAt - 1) _
& NewString _
& Mid(myCell.Value, P_POS_StartsAt _
+ Len(StrP_POS))

Else
'do nothing
End If
End If
Next myCell
End With

End Sub

Hammer_757 wrote:

I am working with a spreadsheet that is being used primarily as a
database with several elements of alphanumeric data in each cell. I
need to search for cells that are missing an element “(3-2)” and then
search for something else “P POS” within the cell, replace it with
something, and continue checking the remaining cells. If a cell has
“(3-2)” in it I need to bypass the cell.

I cannot just search for “P POS” because it needs to remain in the
cells that contain (3-2).

For starters, I cannot seem to figure out how to find the absence of
something…

Thanks in advance
Robert

--
Hammer_757
------------------------------------------------------------------------
Hammer_757's Profile: http://www.excelforum.com/member.php...fo&userid=7413
View this thread: http://www.excelforum.com/showthread...hreadid=313991


--

Dave Peterson
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
search data? kyoshirou Excel Discussion (Misc queries) 6 June 1st 07 09:34 AM
Data Search Airfive Excel Discussion (Misc queries) 3 May 11th 07 01:53 AM
Data Search Airfive Excel Worksheet Functions 2 November 20th 06 06:43 PM
Search through Data adz New Users to Excel 1 October 5th 06 07:39 AM
Search for data using 'contains' JaB Excel Discussion (Misc queries) 1 November 10th 05 12:47 PM


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