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 Help With CODE!!!

I run a standard find macro but if the file i try to import does not
have the particular find command (in the sample case below it's "PUP")
then my code breaks and I have an error
Is there anything i can input that will allow me to say that if the
word "PUP" is not there, then dont do anything, but if it's there, then
run my code below.



Windows("2.txt").Activate
Cells.Find(What:="PUP", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("K10").Select
ActiveSheet.Paste


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 194
Default Need Help With CODE!!!

Look through the examples in the VBA Help under On Error Statement and On
Error Statement Examples - you should find something that will fit your
code.

Ed

"alexm999 " wrote in message
...
I run a standard find macro but if the file i try to import does not
have the particular find command (in the sample case below it's "PUP")
then my code breaks and I have an error
Is there anything i can input that will allow me to say that if the
word "PUP" is not there, then dont do anything, but if it's there, then
run my code below.



Windows("2.txt").Activate
Cells.Find(What:="PUP", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("K10").Select
ActiveSheet.Paste


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help With CODE!!!

I did check. I'm new to VB and dont know what to put in exactly.
Can anyone help

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need Help With CODE!!!

On Error Resume Next
Range.Find(Target).Activate
On Error goto 0

--
regards,
Tom Ogilvy

"alexm999 " wrote in message
...
I did check. I'm new to VB and dont know what to put in exactly.
Can anyone help?


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need Help With CODE!!!

What do i put in for "target"

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Need Help With CODE!!!

Alex,

Try this alternative

Windows("2.txt").Activate
Set ofound = Cells.Find(What:="PUP", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False, _
SearchFormat:=False)
If Not ofound Is Nothing Then
ActiveCell.Offset(rowOffset:=0, columnOffset:=6).Activate
Selection.Copy
Windows("DAILY OPERATIONS_2004.xls").Activate
Range("K10").Select
ActiveSheet.Paste

--

HTH

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

"alexm999 " wrote in message
...
What do i put in for "target" ?


---
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Code to conditional format all black after date specified in code? wx4usa Excel Discussion (Misc queries) 3 December 26th 08 07:06 PM
Drop Down/List w/Code and Definition, only code entered when selec Spiritdancer Excel Worksheet Functions 2 November 2nd 07 03:57 AM
Convert a Number Code to a Text Code Traye Excel Discussion (Misc queries) 3 April 6th 07 09:54 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM


All times are GMT +1. The time now is 06:40 AM.

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"