#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Find Macro

Hi there,

I'm working on a macro to find items within my database. I
found the code below in the help files, but can't get it
working in my worksheet.

I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what the
pop up in VB tells me. How do I define this?

Also I want to change the code a little to lookin another
worksheet. Is this do-able with this code or is there a
simpler way??

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <
firstAddress
End If
End With

Cheers,

Sue
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default Find Macro

Hello Sue
I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what the
pop up in VB tells me. How do I define this?

Either add this line :
Dim c
Or:
in the VB Editor go to Tools, Options, Editor tab and untick the second
option

Also I want to change the code a little to lookin another
worksheet. Is this do-able with this code or is there a
simpler way??


Amend this line With Worksheets(1).Range("a1:a500")
with the relevant worksheet name and range eg:
With Worksheets("YourSheetName").Range("B1:B500")

HTH
Cordially
Pascal


"Sue M" a écrit dans le message de
...
Hi there,

I'm working on a macro to find items within my database. I
found the code below in the help files, but can't get it
working in my worksheet.

I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what the
pop up in VB tells me. How do I define this?

Also I want to change the code a little to lookin another
worksheet. Is this do-able with this code or is there a
simpler way??

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <
firstAddress
End If
End With

Cheers,

Sue



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Find Macro

Hi,
the worksheet in your code is 1 and the range is A1:A500
it is possible to change as you want ....

With Worksheets(1).Range("a1:a500")

With Worksheets("test").Range("a1:X5700")


--
....Patrick
Quoi que vous fassiez, faites le bien .
Mail: http://cerbermail.com/?KPW0tTCjFw
Connectez vous sur ce forum par :
news://msnews.microsoft.com/microsoft.public.fr.excel


"Sue M" a écrit dans le message de
...
Hi there,

I'm working on a macro to find items within my database. I
found the code below in the help files, but can't get it
working in my worksheet.

I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what the
pop up in VB tells me. How do I define this?

Also I want to change the code a little to lookin another
worksheet. Is this do-able with this code or is there a
simpler way??

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <
firstAddress
End If
End With

Cheers,

Sue



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Find Macro

Thanks I have it going now.

both c and first adress needed the Dim thing.

Cheers,

Sue
-----Original Message-----
Hello Sue
I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what

the
pop up in VB tells me. How do I define this?

Either add this line :
Dim c
Or:
in the VB Editor go to Tools, Options, Editor tab and

untick the second
option

Also I want to change the code a little to lookin

another
worksheet. Is this do-able with this code or is there a
simpler way??


Amend this line With Worksheets(1).Range("a1:a500")
with the relevant worksheet name and range eg:
With Worksheets("YourSheetName").Range("B1:B500")

HTH
Cordially
Pascal


"Sue M" a écrit

dans le message de
...
Hi there,

I'm working on a macro to find items within my

database. I
found the code below in the help files, but can't get it
working in my worksheet.

I have a feeling that this has something to do with the
variable (c) not being defined - at least that's what

the
pop up in VB tells me. How do I define this?

Also I want to change the code a little to lookin

another
worksheet. Is this do-able with this code or is there a
simpler way??

With Worksheets(1).Range("a1:a500")
Set c = .Find(2, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.Interior.Pattern = xlPatternGray50
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <
firstAddress
End If
End With

Cheers,

Sue



.

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
Macro-find and sum puiuluipui Excel Discussion (Misc queries) 5 October 19th 09 01:44 AM
find max value in macro Steve Excel Discussion (Misc queries) 2 January 6th 09 10:01 PM
Get Macro warning, but can't find Macro Stilla Excel Worksheet Functions 1 January 20th 07 01:27 AM
Cannot find macro New users New Users to Excel 2 February 17th 05 05:01 PM
Can't find macro Jim Excel Worksheet Functions 2 December 2nd 04 01:26 PM


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