Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using IF to locate specific text string value

I would like to use a macro to find in a spreadsheet all specific text string
values and then change the left adjacent cell value to display "N/A". While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Using IF to locate specific text string value

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist", "exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text string
values and then change the left adjacent cell value to display "N/A". While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Using IF to locate specific text string value

sorry, in case 2, meant B2:H2:
= IF( COUNTIF(B2:H2,"Hello")0, "exist", "does not exist" )

sebastien
"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist", "exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text string
values and then change the left adjacent cell value to display "N/A". While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using IF to locate specific text string value

Sorry for being so confusing, cut and paste will not work as those cells are
already populated. So I cannot place a formula in there or I will lose data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number. and
the adjacent cell which already has a value I want to have NA overwrite that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we want to
remove that response data in the adjacent cell and replace it with NA. Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist", "exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text string
values and then change the left adjacent cell value to display "N/A". While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using IF to locate specific text string value

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those cells

are
already populated. So I cannot place a formula in there or I will lose

data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number. and
the adjacent cell which already has a value I want to have NA overwrite

that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we want

to
remove that response data in the adjacent cell and replace it with NA.

Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",

"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text

string
values and then change the left adjacent cell value to display "N/A".

While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using IF to locate specific text string value

This partially works, but it also takes all values starting with one for some
reason and marks them "NA" such as n=11 n=19 etc.

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those cells

are
already populated. So I cannot place a formula in there or I will lose

data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number. and
the adjacent cell which already has a value I want to have NA overwrite

that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we want

to
remove that response data in the adjacent cell and replace it with NA.

Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",

"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text

string
values and then change the left adjacent cell value to display "N/A".

While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using IF to locate specific text string value

I figured it out its the xlPart should be xlWhole for a specific string.

"Metalmaiden" wrote:

This partially works, but it also takes all values starting with one for some
reason and marks them "NA" such as n=11 n=19 etc.

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those cells

are
already populated. So I cannot place a formula in there or I will lose

data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number. and
the adjacent cell which already has a value I want to have NA overwrite

that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we want

to
remove that response data in the adjacent cell and replace it with NA.

Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",

"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific text

string
values and then change the left adjacent cell value to display "N/A".

While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using IF to locate specific text string value

Sub MarkwithNA()
Dim rng as Range
Dim fAddr as String
for i = 1 to 9
set rng = Nothing
set rng = Cells.Find("n=" & i, _
Lookin:=xlValues, lookat:=xlWhole)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
Next
End Sub


--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
This partially works, but it also takes all values starting with one for

some
reason and marks them "NA" such as n=11 n=19 etc.

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those

cells
are
already populated. So I cannot place a formula in there or I will lose

data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number.

and
the adjacent cell which already has a value I want to have NA

overwrite
that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we

want
to
remove that response data in the adjacent cell and replace it with NA.

Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is

outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",

"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific

text
string
values and then change the left adjacent cell value to display

"N/A".
While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.







  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Using IF to locate specific text string value

Thanks for the response this is very elegant and reduces redundancy!!!

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
Dim fAddr as String
for i = 1 to 9
set rng = Nothing
set rng = Cells.Find("n=" & i, _
Lookin:=xlValues, lookat:=xlWhole)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
Next
End Sub


--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
This partially works, but it also takes all values starting with one for

some
reason and marks them "NA" such as n=11 n=19 etc.

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those

cells
are
already populated. So I cannot place a formula in there or I will lose
data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number.

and
the adjacent cell which already has a value I want to have NA

overwrite
that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we

want
to
remove that response data in the adjacent cell and replace it with NA.
Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is

outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",
"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific

text
string
values and then change the left adjacent cell value to display

"N/A".
While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.








  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Using IF to locate specific text string value

The difference between the two is whether you want to find the string ONLY if
that's all that's in the cell, or if it's embedded within a longer string.

On Sat, 9 Oct 2004 15:23:01 -0700, "Metalmaiden"
wrote:

I figured it out its the xlPart should be xlWhole for a specific string.

"Metalmaiden" wrote:

This partially works, but it also takes all values starting with one for

some
reason and marks them "NA" such as n=11 n=19 etc.

"Tom Ogilvy" wrote:

Sub MarkwithNA()
Dim rng as Range
set rng = Cells.Find("n=#", _
Lookin:=xlValues, lookat:=xlPart)
if not rng is nothing then
fAddr = rng.Address
do
rng.offset(0,-1) = "NA"
set rng = cells.findnext(rng)
loop while rng.Address < fAddr
End if
End Sub

--
Regards,
Tom Ogilvy



"Metalmaiden" wrote in message
...
Sorry for being so confusing, cut and paste will not work as those

cells
are
already populated. So I cannot place a formula in there or I will lose
data I
wish to retain.

I want NA when the string exists "n=#" where # could equal any number.

and
the adjacent cell which already has a value I want to have NA overwrite
that
value. While leaving all other values in place.

It is a response report and if there are not sufficent responses we

want
to
remove that response data in the adjacent cell and replace it with NA.
Since
it is not meaningful or statistically significant.

What I would like to do is place it in a macro because this is

outputted
data and already completely formatted.

"sebastienm" wrote:

Do you want NA when the string exists? or when it deosn't exist?
In the left cell, say A2:

1. Using VHLOOKUP:
-- if count of the string is greater than zero then NA else "ok"
=IF ( ISNA(VLOOKUP("Hello" , B2:H2 , 1, FALSE)), "doesn't exist",
"exist")

2. Using Countif
= IF( COUNTIF(B2:B10,"Hello")0, "exist", "does not exist" )

Copy/paste down along the data.
Regards,
Sebastien
"Metalmaiden" wrote:

I would like to use a macro to find in a spreadsheet all specific

text
string
values and then change the left adjacent cell value to display

"N/A".
While
leaving the specific value alone.

There are approximately 9 string values. n=#.

I need to use this function alot so I would like to add it to the
personal.xls for all the workbooks using this worksheet.






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
Need formula to locate and validate specific text from a string vinstream Excel Discussion (Misc queries) 11 April 7th 10 12:52 PM
Nested formula to search a text string and return specific text Barbie Excel Worksheet Functions 10 February 21st 09 07:40 AM
locate cell with specific text and select that column rockytopfan4ever Excel Discussion (Misc queries) 3 July 30th 08 01:53 PM
Locate and count the recurrences of a text string Trish2 Excel Discussion (Misc queries) 1 March 8th 06 03:02 PM
can you find specific text in a string ignoring any other text chriscp Excel Discussion (Misc queries) 1 September 18th 05 09:54 PM


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