PC Review


Reply
 
 
Mike Archer
Guest
Posts: n/a
 
      5th Feb 2008
Hello. I pasted a macro below. An error occurs when the line for Cells.Find
is executed. It is error 91 (object or variable not found). I have
experiemented with the "What" criteria. If the variable string PPMDate is
more than 1 character, the error occurs. If is 1 charter or empty, the error
does not occur. Could someone clue me in on this?

Thanks in advance,
Mike

Private Sub CopyData()

Dim PPMData As String

Dim PPMDate As String

' Get the Escape number

Selection.Offset(0, 9).Select



' If the cell is blank then force to zero

PPMData = ActiveCell.Value

If Not IsNumeric(PPMData) Then PPMData = "0"



Workbooks(myWorkbookName).Activate

Sheets("PPM_Data").Select

PPMDate = Replace(ReadWorkbookName, ".xls", "")

PPMDate = Format(PPMDate, "m/d/yyyy")

Range("A1").Select

'Error 91 Occurs here:

Cells.Find(What:=PPMDate, After:=ActiveCell, LookIn:=xlFormulas, _

LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _

MatchCase:=False, SearchFormat:=False).Activate



Selection.Offset(0, 5).Select

ActiveCell.Value = PPMData



' Now get the Catch number

Workbooks(ReadWorkbookName).Activate

Selection.Offset(-1, 0).Select



' If the cell is blank then force to zero

PPMData = ActiveCell.Value

If Not IsNumeric(PPMData) Then PPMData = "0"



Workbooks(myWorkbookName).Activate

Selection.Offset(0, -1).Select

ActiveCell.Value = PPMData



End Sub


--
Thanks,
Mike
 
Reply With Quote
 
 
 
 
Jim Thomlinson
Guest
Posts: n/a
 
      5th Feb 2008
Your code is doing a find looking for partial matches on your text string. If
no match is found your code will bomb. We can deal with the part where it
bombs without too much difficutly but are you looking for a text string in a
group of actual dates. If that is the case then this code is never going to
work. Actually looking for dates is just generally problematic. If however
you are looking to a text string of the format mm/dd/yyyy in a group of text
strings of similar format then we have a shot at this...
--
HTH...

Jim Thomlinson


"Mike Archer" wrote:

> Hello. I pasted a macro below. An error occurs when the line for Cells.Find
> is executed. It is error 91 (object or variable not found). I have
> experiemented with the "What" criteria. If the variable string PPMDate is
> more than 1 character, the error occurs. If is 1 charter or empty, the error
> does not occur. Could someone clue me in on this?
>
> Thanks in advance,
> Mike
>
> Private Sub CopyData()
>
> Dim PPMData As String
>
> Dim PPMDate As String
>
> ' Get the Escape number
>
> Selection.Offset(0, 9).Select
>
>
>
> ' If the cell is blank then force to zero
>
> PPMData = ActiveCell.Value
>
> If Not IsNumeric(PPMData) Then PPMData = "0"
>
>
>
> Workbooks(myWorkbookName).Activate
>
> Sheets("PPM_Data").Select
>
> PPMDate = Replace(ReadWorkbookName, ".xls", "")
>
> PPMDate = Format(PPMDate, "m/d/yyyy")
>
> Range("A1").Select
>
> 'Error 91 Occurs here:
>
> Cells.Find(What:=PPMDate, After:=ActiveCell, LookIn:=xlFormulas, _
>
> LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
>
> MatchCase:=False, SearchFormat:=False).Activate
>
>
>
> Selection.Offset(0, 5).Select
>
> ActiveCell.Value = PPMData
>
>
>
> ' Now get the Catch number
>
> Workbooks(ReadWorkbookName).Activate
>
> Selection.Offset(-1, 0).Select
>
>
>
> ' If the cell is blank then force to zero
>
> PPMData = ActiveCell.Value
>
> If Not IsNumeric(PPMData) Then PPMData = "0"
>
>
>
> Workbooks(myWorkbookName).Activate
>
> Selection.Offset(0, -1).Select
>
> ActiveCell.Value = PPMData
>
>
>
> End Sub
>
>
> --
> Thanks,
> Mike

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple code to find the empty cells in a range and cells with number Subodh Microsoft Excel Programming 2 30th Apr 2010 06:05 AM
RE: Need Cells.find to find first number in a row which is >8000 Trevor Williams Microsoft Excel Misc 3 15th Dec 2008 01:29 PM
how to find cells that refer to data in other cells in excel Aman Microsoft Excel Misc 8 2nd Dec 2007 10:02 PM
Excel- find the last filled cells in column with empty cells sde_us@swbell.net Microsoft Excel Programming 1 28th Sep 2007 12:20 AM
How to find multiple cells/replace whole cells w/data =?Utf-8?B?ZGN1cnlsbw==?= Microsoft Excel Misc 2 30th Nov 2005 08:06 PM


Features
 

Advertising
 

Newsgroups
 


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