Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro works, then doesn't


Why does this code work one day, then the next it does not?
I have to write a new code every time I launch this WB WHY??

My security is set to LOW now, and trusted sources are both checked.
It ONLY happenes in this workbook, the codes work in others just fine, what
could be the problem with this workbook ( if the code is right?)
Thanks in advance if you can help.

Sub FindThis()
Dim rngToSearch As Range
Dim rngFound As Range
Dim wks As Worksheet
Set wks = ActiveSheet
Set rngToSearch = Worksheets("Schedule").Range("A4:A5205")
Set rngFound = rngToSearch.Find(What:=wks.Range("$A$1"), _
LookAt:=xlPart, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto Range(rngFound.Address), True


Else
MsgBox "Not Found"
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro works, then doesn't

I'd specify all the parms in the .find statement.

And this line:
Application.Goto Range(rngFound.Address), true
will go to the same address as rngFound--but on the activesheet.

Maybe you want:
Application.Goto rngFound, true

=====
And make sure you save that workbook after you type in the code. (Are you
putting the code in that same workbook--and that workbook isn't being deleted
and recreated each day???)


Oddball wrote:

Why does this code work one day, then the next it does not?
I have to write a new code every time I launch this WB WHY??

My security is set to LOW now, and trusted sources are both checked.
It ONLY happenes in this workbook, the codes work in others just fine, what
could be the problem with this workbook ( if the code is right?)
Thanks in advance if you can help.

Sub FindThis()
Dim rngToSearch As Range
Dim rngFound As Range
Dim wks As Worksheet
Set wks = ActiveSheet
Set rngToSearch = Worksheets("Schedule").Range("A4:A5205")
Set rngFound = rngToSearch.Find(What:=wks.Range("$A$1"), _
LookAt:=xlPart, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto Range(rngFound.Address), True


Else
MsgBox "Not Found"
End If
End Sub


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro works, then doesn't

Dave,
Thanks for your reply.
This has also had no effect.
I wonder... I have been creating all my workbooks on a different computer ,
then I copied them, took them home and mixed and matched my already proven
macros from my prior WB's into this one that I just created here at home.
I obviously had to edit the addresses of the ranges within most of the
codes, but the very first time I edited them, they worked... all day, until I
saved and shut down my PC .I started it up again the next day, opened this
WB to continue working on scheduling my employees but ALL the various "Find"
macros ( all are copied from other WB's, renamed and edited) do not work.
All the ones I've actually written (recorded) while working on this WB work
just fine.
All the "Find" macros work in their original WBs on this PC.

Btw, the PC the other WB's were created on no longer exists, I have migrated
all WBs home.


"Dave Peterson" wrote:

I'd specify all the parms in the .find statement.

And this line:
Application.Goto Range(rngFound.Address), true
will go to the same address as rngFound--but on the activesheet.

Maybe you want:
Application.Goto rngFound, true

=====
And make sure you save that workbook after you type in the code. (Are you
putting the code in that same workbook--and that workbook isn't being deleted
and recreated each day???)


Oddball wrote:

Why does this code work one day, then the next it does not?
I have to write a new code every time I launch this WB WHY??

My security is set to LOW now, and trusted sources are both checked.
It ONLY happenes in this workbook, the codes work in others just fine, what
could be the problem with this workbook ( if the code is right?)
Thanks in advance if you can help.

Sub FindThis()
Dim rngToSearch As Range
Dim rngFound As Range
Dim wks As Worksheet
Set wks = ActiveSheet
Set rngToSearch = Worksheets("Schedule").Range("A4:A5205")
Set rngFound = rngToSearch.Find(What:=wks.Range("$A$1"), _
LookAt:=xlPart, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto Range(rngFound.Address), True


Else
MsgBox "Not Found"
End If
End Sub


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro works, then doesn't

What does "not work" mean?

Does it mean that the macro doesn't even run (make sure macros are enabled).

Does it mean that you get the "Not Found" message back? Maybe you didn't type a
string that was found???

Oddball wrote:

Dave,
Thanks for your reply.
This has also had no effect.
I wonder... I have been creating all my workbooks on a different computer ,
then I copied them, took them home and mixed and matched my already proven
macros from my prior WB's into this one that I just created here at home.
I obviously had to edit the addresses of the ranges within most of the
codes, but the very first time I edited them, they worked... all day, until I
saved and shut down my PC .I started it up again the next day, opened this
WB to continue working on scheduling my employees but ALL the various "Find"
macros ( all are copied from other WB's, renamed and edited) do not work.
All the ones I've actually written (recorded) while working on this WB work
just fine.
All the "Find" macros work in their original WBs on this PC.

Btw, the PC the other WB's were created on no longer exists, I have migrated
all WBs home.

"Dave Peterson" wrote:

I'd specify all the parms in the .find statement.

And this line:
Application.Goto Range(rngFound.Address), true
will go to the same address as rngFound--but on the activesheet.

Maybe you want:
Application.Goto rngFound, true

=====
And make sure you save that workbook after you type in the code. (Are you
putting the code in that same workbook--and that workbook isn't being deleted
and recreated each day???)


Oddball wrote:

Why does this code work one day, then the next it does not?
I have to write a new code every time I launch this WB WHY??

My security is set to LOW now, and trusted sources are both checked.
It ONLY happenes in this workbook, the codes work in others just fine, what
could be the problem with this workbook ( if the code is right?)
Thanks in advance if you can help.

Sub FindThis()
Dim rngToSearch As Range
Dim rngFound As Range
Dim wks As Worksheet
Set wks = ActiveSheet
Set rngToSearch = Worksheets("Schedule").Range("A4:A5205")
Set rngFound = rngToSearch.Find(What:=wks.Range("$A$1"), _
LookAt:=xlPart, MatchCase:=False)

If Not rngFound Is Nothing Then
Application.Goto Range(rngFound.Address), True


Else
MsgBox "Not Found"
End If
End Sub


--

Dave Peterson


--

Dave Peterson
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 do works in excel... driller Excel Worksheet Functions 7 July 12th 07 02:56 PM
Macro works on one computer but not another Dagonini Excel Programming 3 February 21st 07 04:37 PM
Macro Only works Once [email protected] Excel Programming 8 December 28th 06 11:42 PM
Macro works once, not twice Madvark Excel Programming 6 June 18th 04 11:00 PM
macro works in .xlt but not .xls BrianG[_3_] Excel Programming 6 September 18th 03 10:13 PM


All times are GMT +1. The time now is 08:54 PM.

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"