Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Ending Looping Macro


I've got this code that is giving me an error (Run time Error '91').

The code is looking for formulas that begin with "=XXX" and copy/paste
values any cell that contains this formula.

Here is the code:
Sub XXX()
Cells.Find(What:="=XXX", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

Sub XXX_Loop()
Do
XXX
Loop
End Sub

You can probably tell that when Excel doesn't find any additional
"=XXX" formulas, the error message pops up. I've tried a few things
and nothing seems to work.

Although the macro is doing what it needs to do, I'd like to have a
"cleaner" running macro that doesn't end with an error message. Any
help will be greatly appreciated.

EDIT: The simple solution would be to copy/paste values the whole
worksheet but I would like to leave some "live" formulas (e.g.
"=A24/A25") that do not start with the "=XXX" custom function.

Thanks,
cparaske


--
cparaske
------------------------------------------------------------------------
cparaske's Profile: http://www.excelforum.com/member.php...fo&userid=3793
View this thread: http://www.excelforum.com/showthread...hreadid=378646

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


Hi

Code:
--------------------

Sub XXX()
Dim r As Range, myStr As String
myStr = "=" & Chr(34) & "XXX" & Chr(34)
Set r = Cells.Find(What:=myStr, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
If Not r Is Nothing Then
r = r.Value
While Not r Is Nothing
Set r = Cells.FindNext(r)
If Not r Is Nothing Then
r = r.Value
End If
Wend
End If
End Sub

--------------------

I've got this code that is giving me an error (Run time Error '91').

The code is looking for formulas that begin with "=XXX" and copy/paste
values any cell that contains this formula.

Here is the code:
Sub XXX()
Cells.Find(What:="=XXX", After:=ActiveCell, LookIn:=xlFormulas, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=
_
False, SearchFormat:=False).Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End Sub

Sub XXX_Loop()
Do
XXX
Loop
End Sub

You can probably tell that when Excel doesn't find any additional
"=XXX" formulas, the error message pops up. I've tried a few things and
nothing seems to work.

Although the macro is doing what it needs to do, I'd like to have a
"cleaner" running macro that doesn't end with an error message. Any
help will be greatly appreciated.

Thanks,
cparaske



--
jindon
------------------------------------------------------------------------
jindon's Profile: http://www.excelforum.com/member.php...o&userid=13135
View this thread: http://www.excelforum.com/showthread...hreadid=378646

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


Thanks, jindon.

It worked like a charm.

Kind regards,
Cristo


--
cparaske
------------------------------------------------------------------------
cparaske's Profile: http://www.excelforum.com/member.php...fo&userid=3793
View this thread: http://www.excelforum.com/showthread...hreadid=378646

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
Ending Macro in Last Row within a column of Printable Items MrMike Excel Worksheet Functions 7 April 7th 10 10:28 PM
Looping a macro Sony Excel Discussion (Misc queries) 3 October 30th 06 11:52 AM
Ending a macro early conditionally on one cell being blank Rokuro kubi Excel Discussion (Misc queries) 3 May 26th 06 02:09 PM
macro not ending Josie Excel Programming 3 October 6th 04 02:56 PM
Looping Macro Pete Excel Programming 3 February 18th 04 05:33 PM


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