Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Using a Macro to find a value in a range and activate it

Hi Travis,

travis wrote:
I think I've left a couple important bits out....the cell
that contains the primary search value is on a different
sheet ("Add-Remove") than the the sheet containing the
range I want to find it in ("Lists"). In addition, once I
find the cell in the range that contains the correct value
(which will be in column a), I want to delete the contents
of the cells in colums B,C,D,E and V in the same row as
the 'found' cell


Yes, those are important things to know. <g

Try this one instead:

Public Sub FindMatch(rvFindWhat As Variant, _
rrngTarget As Range, Optional rbMatchCase As _
Boolean = True)
Dim rng As Range

On Error Resume Next
Set rng = rrngTarget.Find(What:=rvFindWhat, _
MatchCase:=rbMatchCase)
On Error GoTo 0

If Not rng Is Nothing Then
With rng.Parent
.Cells(rng.Row, 2).ClearContents
.Cells(rng.Row, 3).ClearContents
.Cells(rng.Row, 4).ClearContents
.Cells(rng.Row, 5).ClearContents
.Cells(rng.Row, 22).ClearContents
End With
End If
End Sub

Public Sub Test()
With Sheets("List")
FindMatch Sheets("Add-Remove").Range("A1"). _
Value, Application.Intersect(.Range("A:A") _
, .UsedRange)
End With
End Sub


You'll notice that I don't select or activate anything. This will increase
performance and leave the user's current selection alone.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]

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 to find value and then copy associated range hnyb1 Excel Discussion (Misc queries) 1 December 31st 09 04:09 PM
Activate cell at end of range G Setting up and Configuration of Excel 2 November 22nd 05 04:10 PM
use of range and activate crichardson Excel Programming 4 March 2nd 04 03:29 PM
range.activate Rune_Daub[_16_] Excel Programming 1 February 12th 04 06:55 PM
Macro to find the 6th occurrence and move range cynthia Excel Programming 0 January 22nd 04 03:48 AM


All times are GMT +1. The time now is 12:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"