LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default VBA Problem

Melanie,

Following on from previous message, I found the ideal
solution..........

On Error Resume Next

It may not be elegant and there is an underlying runtime
error but the result is as required.

Regards

Tom

-----Original Message-----
Melanie,

Thanks for your reply. I'm not a programmer per se but
use the record macro facility of excel to do what I want
plus I do some limited and simple VBA coding to enhance.

I've been down the route you have suggested but come
upto a brick wall when refining and making code more
efficient. Another MVP has been extremely helpful in
this (Dick Kusleika) but we are at the stage whereby if
the column contains physical (e.g. typed input) values

of
1 or 2 or Ladies then OK but if it contains these values
from cell formula (which is the case) then these values
are never found. I/we don't know why.

I'm therefore reverting back to "simplistic" recorded

code
which brings up issue I described - and which I started
with Again, don't know why I get an error searching for
the text Ladies in a column but not when searching for a
Number such as 1 or 2. Is it as simple as numeric -v-
text ?? If so how do I overcome?? Using recorded
mechanism seem to negate whether physical or formula
values

What I'm doing is searching a column (700 rows), looking
for the first 3 instances each of the number 1, number 2
and the word Ladies. The macro has thus been recorded 3
times. I copy each occurance to separate sheet.

The only problem is if there are no Ladies ????????
That's when I get the error; otherwise works fine.

Regards

Tom


-----Original Message-----
Hi Tom,

TomD wrote:
I have this code as part of a "Show Winners" macro
button..........

Cells.Find(What:="Ladies", After:=ActiveCell,
LookIn:=xlValues, LookAt:= _
xlPart, SearchOrder:=xlByColumns,
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate

Which, if Ladies not found (because button activated
without any entries being made in spreadsheet),

gives....

Runtime error 91
Object variable or With Block varibale not set.


try this:

Dim rngFind As Range

Set rngFind = _
Cells.Find(What:="Ladies", After:=ActiveCell, _
LookIn:=xlValues, LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext, MatchCase:=False, _
SearchFormat:=False)

If Not rngFind Is Nothing Then rngFind.Select

--
Mit freundlichen Grüssen

Melanie Breden
- Microsoft MVP für Excel -

http://excel.codebooks.de (Das Excel-VBA Codebook)

.

.

 
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
Colon at the end of excel file name(ex: problem.xls:1, problem.xls financeguy New Users to Excel 2 January 15th 10 01:15 AM
Started out as an Access problem. Now an Excel problem RobertM Excel Discussion (Misc queries) 2 April 26th 06 07:30 PM
problem with a conditional max problem Brian Cornejo Excel Discussion (Misc queries) 1 February 18th 05 06:25 PM


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