Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
nis75p06
 
Posts: n/a
Default Edit macro to match entire cell contents


I'm using the following macro:

Sub rename()
Dim c As Range
Set c = Range("B:B").Find(ActiveCell)
If c Is Nothing Then Exit Sub
ActiveCell = c.Offset(, -1)
End Sub

I need to edit it so that the find is for "match entire cell contents"

Thanks for the help!

-Tamara


--
nis75p06
------------------------------------------------------------------------
nis75p06's Profile: http://www.excelforum.com/member.php...o&userid=26949
View this thread: http://www.excelforum.com/showthread...hreadid=401692

  #2   Report Post  
Don Guillett
 
Posts: n/a
Default

from HELP index for FIND
Find Method
See Also Applies To Example Specifics
Find method as it applies to the WorksheetFunction object.

Finds specific information in a worksheet.

expression.Find(Arg1, Arg2, Arg3)

expression Required. An expression that returns a WorksheetFunction
object.

Arg1 Required String. The name of the worksheet.

Arg2 Required String. The name of the range.

Arg3 Optional Variant. The name of an argument to refine the search.

Find method as it applies to the Range object.

Finds specific information in a range, and returns a Range object that
represents the first cell where that information is found. Returns Nothing
if no match is found. Doesn’t affect the selection or the active cell.

For information about using the Find worksheet function in Visual Basic, see
Using Worksheet Functions in Visual Basic.

expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection,
MatchCase, MatchByte, SearchFormat)

expression Required. An expression that returns a Range object.

What Required Variant. The data to search for. Can be a string or any
Microsoft Excel data type.

After Optional Variant. The cell after which you want the search to begin.
This corresponds to the position of the active cell when a search is done
from the user interface. Note that After must be a single cell in the range.
Remember that the search begins after this cell; the specified cell isn’t
searched until the method wraps back around to this cell. If you don’t
specify this argument, the search starts after the cell in the upper-left
corner of the range.

LookIn Optional Variant. The type of information.

LookAt Optional Variant. Can be one of the following XlLookAt constants:
xlWhole or xlPart.

SearchOrder Optional Variant. Can be one of the following XlSearchOrder
constants: xlByRows or xlByColumns.

SearchDirection Optional XlSearchDirection. The search direction.

XlSearchDirection can be one of these XlSearchDirection constants.
xlNext default
xlPrevious

MatchCase Optional Variant. True to make the search case sensitive. The
default value is False.

MatchByte Optional Variant. Used only if you’ve selected or installed
double-byte language support. True to have double-byte characters match only
double-byte characters. False to have double-byte characters match their
single-byte equivalents.

SearchFormat Optional Variant. The search format.

Remarks
The settings for LookIn, LookAt, SearchOrder, and MatchByte are saved each
time you use this method. If you don’t specify values for these arguments
the next time you call the method, the saved values are used. Setting these
arguments changes the settings in the Find dialog box, and changing the
settings in the Find dialog box changes the saved values that are used if
you omit the arguments. To avoid problems, set these arguments explicitly
each time you use this method.

You can use the FindNext and FindPrevious methods to repeat the search.

When the search reaches the end of the specified search range, it wraps
around to the beginning of the range. To stop a search when this wraparound
occurs, save the address of the first found cell, and then test each
successive found-cell address against this saved address.

To find cells that match more complicated patterns, use a For Each...Next
statement with the Like operator. For example, the following code searches
for all cells in the range A1:C5 that use a font whose name starts with the
letters Cour. When Microsoft Excel finds a match, it changes the font to
Times New Roman.

For Each c In [A1:C5]
If c.Font.Name Like "Cour*" Then
c.Font.Name = "Times New Roman"
End If
NextExample
This example finds all cells in the range A1:A500 on worksheet one that
contain the value 2 and changes it to 5.

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, lookin:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Value = 5
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
--
Don Guillett
SalesAid Software

"nis75p06" wrote in
message ...

I'm using the following macro:

Sub rename()
Dim c As Range
Set c = Range("B:B").Find(ActiveCell)
If c Is Nothing Then Exit Sub
ActiveCell = c.Offset(, -1)
End Sub

I need to edit it so that the find is for "match entire cell contents"

Thanks for the help!

-Tamara


--
nis75p06
------------------------------------------------------------------------
nis75p06's Profile:

http://www.excelforum.com/member.php...o&userid=26949
View this thread: http://www.excelforum.com/showthread...hreadid=401692







Attached Images
  
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 help - copy a cell down gjcase Excel Discussion (Misc queries) 3 September 4th 05 05:09 AM
Printing Entire Contents of Cell waterdawg Excel Discussion (Misc queries) 1 August 31st 05 09:03 PM
Copy cell format to cell on another worksht and update automatical kevinm Excel Worksheet Functions 21 May 19th 05 11:07 AM
How can I edit cell contents with a macro in Excel? Mind the gaps! Excel Discussion (Misc queries) 2 March 23rd 05 08:51 PM
How can I edit cell contents with a macro in Excel? NotAnExpert Excel Discussion (Misc queries) 1 March 23rd 05 01:17 AM


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