Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Quick Fix... Find macro Issue

Im running a simple Find macro to populate cells from another file. Th
problem im having is when the term im finding is not there, my macr
breaks and stops... Is there a way i can bypass or do something tha
will jump to the next find if the first find was not found?

Here's my Code:

Windows("10.txt").Activate
Cells.Find(WHAT:="DDCE", After:=ActiveCell, LookIn:=xlFormulas
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
Windows("10.txt").Activate
Cells.Find(WHAT:="EXT", After:=ActiveCell, LookIn:=xlFormulas
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("J18").Select
ActiveSheet.Past

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need Quick Fix... Find macro Issue

Alex,

Dos this help

Dim sSave As String
Windows("10.txt").Activate
sSave = ActiveCell.Address
On Error Resume Next
Cells.Find(WHAT:="DDCE", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False).Activate
On Error GoTo 0
If ActiveCell.Address < sSave Then
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
Windows("10.txt").Activate
Cells.Find(WHAT:="EXT", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("J18").Select
ActiveSheet.Paste
End If



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"alexm999 " wrote in message
...
Im running a simple Find macro to populate cells from another file. The
problem im having is when the term im finding is not there, my macro
breaks and stops... Is there a way i can bypass or do something that
will jump to the next find if the first find was not found?

Here's my Code:

Windows("10.txt").Activate
Cells.Find(WHAT:="DDCE", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
Windows("10.txt").Activate
Cells.Find(WHAT:="EXT", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("J18").Select
ActiveSheet.Paste


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Need Quick Fix... Find macro Issue

Alex

Try On Error Resume Next where I've put it in your code

Windows("10.txt").Activate

On Error Resume Next

Cells.Find(WHAT:="DDCE", After:=ActiveCell,
LookIn:=xlFormulas,LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= False).Activate


Regards
Peter
-----Original Message-----
Im running a simple Find macro to populate cells from

another file. The
problem im having is when the term im finding is not

there, my macro
breaks and stops... Is there a way i can bypass or do

something that
will jump to the next find if the first find was not

found?

Here's my Code:

Windows("10.txt").Activate
Cells.Find(WHAT:="DDCE", After:=ActiveCell,

LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
Windows("10.txt").Activate
Cells.Find(WHAT:="EXT", After:=ActiveCell,

LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=4).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("J18").Select
ActiveSheet.Paste


---
Message posted from http://www.ExcelForum.com/

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Quick Fix... Find macro Issue

Does help. Now one more problem. And I posted it before with no help...
I have 2 data criteria that Im searching for; DDC and DDCE.
If I have no DDC in theory, the program should then skip to DDCE an
use that data to populate the fields. but whats happening is if DDC i
not there, DDCE data goes into DDC cells.

Is there a way to isolate or stop this from happening?

BTW, the other file that i get the DDC and DDCE data cannot b
altered.
Here's my new revised code:

Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDC", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True)
If Not ofound Is Nothing Then
ofound.Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("C18").Select
ActiveSheet.Paste
End If
Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDCE", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not ofound Is Nothing Then
ofound.Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
End I

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need Quick Fix... Find macro Issue

The problem is you are looking for xlpart rather than xlwhole. Since DDCE
contains DDC, the first finds DDCE when DDC is missing and copies its
associated value to C18, the second find then finds DDCE again and copies
its associated value to E18

Since you are reading in a text file, you probably need to keep the argument
as xlPart, because there are likely to be spaces on the end of the string.
So you need to add an extra test to make sure you have found DDC vice DDCE

Sub AAAATester()
'
' Look for DDC
'
Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDC", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True)
'
' copy won't happen unless the DDC was found
' if found, destination is cell C18
'
If Not ofound Is Nothing Then
ofound.Activate
if Trim(ofound) = "DDC" then
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("C18").Select
ActiveSheet.Paste
End if
End If
'
' Now look for DDCE
'
Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDCE", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
'
' Copy won't occur unless DDCE is found
' if found it is copied to E18
'
If Not ofound Is Nothing Then
ofound.Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
End If

End Sub

--
Regards,
Tom Ogilvy


"alexm999 " wrote in message
...
Does help. Now one more problem. And I posted it before with no help...
I have 2 data criteria that Im searching for; DDC and DDCE.
If I have no DDC in theory, the program should then skip to DDCE and
use that data to populate the fields. but whats happening is if DDC is
not there, DDCE data goes into DDC cells.

Is there a way to isolate or stop this from happening?

BTW, the other file that i get the DDC and DDCE data cannot be
altered.
Here's my new revised code:

Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDC", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True)
If Not ofound Is Nothing Then
ofound.Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=5).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("C18").Select
ActiveSheet.Paste
End If
Windows("10.txt").Activate
Set ofound = Cells.Find(WHAT:="DDCE", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not ofound Is Nothing Then
ofound.Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("E18").Select
ActiveSheet.Paste
End If


---
Message posted from http://www.ExcelForum.com/





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Quick Fix... Find macro Issue

Trim did the trick... Thanks

--
Message posted from http://www.ExcelForum.com

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
find and replace issue in macro ben New Users to Excel 2 December 21st 08 11:50 PM
Quick Find in long drop down list Candyman New Users to Excel 3 May 30th 08 06:29 PM
data validation quick find Richard Excel Discussion (Misc queries) 9 September 22nd 07 01:44 AM
Shortcut Keys -- quick find scottech Excel Discussion (Misc queries) 3 November 15th 05 08:08 PM
excel quick find format chris Excel Worksheet Functions 1 February 9th 05 03:17 AM


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