Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question about using FIND in macros


I have 2 questions about using the Find function in macos.

1) My macro uses Find to search for text and highlights the cel
containing the text. If the text is not found, it throws an error. Ho
can I avoid the error and just continue with the macro? There'
probably an IF clause to be used.

2) If the text is found, it then activates the cell next to it, an
populates it with a value from another tab. Currently, the cel
location in the other tab is hardcoded but I'd like to use the fin
function during referencing that tab. Is this possible? For ex: instea
of saying Range("A1") = Sheet1!("D1"), I want to say Range("A1")
Sheet1!<find text "abc" in column 3 and get the value in the cell nex
to it

As always, thanks a ton

--
cooldyoo
-----------------------------------------------------------------------
cooldyood's Profile: http://www.excelforum.com/member.php...fo&userid=3561
View this thread: http://www.excelforum.com/showthread.php?threadid=56924

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Question about using FIND in macros

#1.

Dim FoundCell as Range
with worksheets("Sheet1")
set foundcell = .cells.find(yourfindstatementhere, ....)
end with
if foundcell is nothing then
'do nothing
else
'do the work
end if


#2. You want to find something on sheet1 and something else in Sheet2 column C?

Dim FoundCell1 as range
dim FoundCell2 as range

with worksheets("Sheet1")
set foundcell1 = .cells.find(yourfindstatementhere, ....)
end with

if foundcell1 is nothing then
'do nothing
msgbox "not found on sheet2"
else
'do the work
with worksheets("sheet2").range("C:C")
set foundcell2 = .cells.find(yourotherfindhere, ...)
end with

if foundcell2 is nothing then
msgbox "not found on sheet2"
else
foundcell1.value = foundcell2.offset(0,1).value
end if
end if

But I'm not sure I really understand.

cooldyood wrote:

I have 2 questions about using the Find function in macos.

1) My macro uses Find to search for text and highlights the cell
containing the text. If the text is not found, it throws an error. How
can I avoid the error and just continue with the macro? There's
probably an IF clause to be used.

2) If the text is found, it then activates the cell next to it, and
populates it with a value from another tab. Currently, the cell
location in the other tab is hardcoded but I'd like to use the find
function during referencing that tab. Is this possible? For ex: instead
of saying Range("A1") = Sheet1!("D1"), I want to say Range("A1") =
Sheet1!<find text "abc" in column 3 and get the value in the cell next
to it

As always, thanks a ton!

--
cooldyood
------------------------------------------------------------------------
cooldyood's Profile: http://www.excelforum.com/member.php...o&userid=35611
View this thread: http://www.excelforum.com/showthread...hreadid=569245


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Question about using FIND in macros


Dave, I think you answered both Qs but I'll try them tomorrow and let
you know.


--
cooldyood
------------------------------------------------------------------------
cooldyood's Profile: http://www.excelforum.com/member.php...o&userid=35611
View this thread: http://www.excelforum.com/showthread...hreadid=569245

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
New to macros - find/move question n412 Excel Programming 8 August 3rd 06 11:08 PM
macros using find/replace TB Excel Programming 1 June 14th 06 11:43 AM
Can't Find Macros DaniBee Excel Discussion (Misc queries) 1 December 6th 05 07:21 PM
macros - Find a list util Excel Discussion (Misc queries) 1 May 4th 05 03:21 PM
can't find macros in template richperfect Excel Programming 1 September 3rd 04 03:42 PM


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