Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 104
Default Endless loop?

John,

If you look in help for FIND, you will see that it will go on for ever if
you don't stop it.
What you need to do is to capture the first address found and check that
Find has not looped back to that address, at the end of your Loop.

Set rngFound = rngToSearch.Find("true")
FirstAdd =rngFound
...
..
..
..
..
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing Or FirstAdd = rngFound

Henry

"John" wrote in message
...
I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian
column
in the sheet equals "true" then cut that row and paste it into a new
sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

Nevermind, I think It is due to the 7000 rows I am trying to sort through...

"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Endless loop?

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

On a smaller sample of data, I have found that the code actually cuts and
copies every row... not just rows that contain "true" in the 24th column.
That is particularly perplexing....

The cut and paste part of the code seems to be working fine however.


"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

is there a way to tell the code to "find" only cell values... rather than the
formula itslef? In other words, is there a way that i won't have to copy and
paste values for the code to work.

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Endless loop?

John,

Are you looking for something like

set rng1 = Sheets("Sheet1").Range("A1:D5")
set rng2 = Sheets("Sheet2").Range("M6:P10")
rng2.value = rng1.value

or
Sheets("Sheet2).Cell(x,y).value = Sheets("Sheet1").Cell(a,b).value

no copy/paste needed.
--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
is there a way to tell the code to "find" only cell values... rather than
the
formula itslef? In other words, is there a way that i won't have to copy
and
paste values for the code to work.

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the
macro.
it has been my experience that the cut and copy commands should not be
used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a
certian column
in the sheet equals "true" then cut that row and paste it into a new
sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

steve,

thanks for the suggestion. I am not sure what that code is doing. Could
you explain what that does so I can figure out how to stick it into my code?

"STEVE BELL" wrote:

John,

Are you looking for something like

set rng1 = Sheets("Sheet1").Range("A1:D5")
set rng2 = Sheets("Sheet2").Range("M6:P10")
rng2.value = rng1.value

or
Sheets("Sheet2).Cell(x,y).value = Sheets("Sheet1").Cell(a,b).value

no copy/paste needed.
--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
is there a way to tell the code to "find" only cell values... rather than
the
formula itslef? In other words, is there a way that i won't have to copy
and
paste values for the code to work.

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the
macro.
it has been my experience that the cut and copy commands should not be
used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a
certian column
in the sheet equals "true" then cut that row and paste it into a new
sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub






  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Endless loop?

hi
yes it seems to work fine but what is happening this the copy/paste uses the
clipboard and it eats up the memory. crash usually occurs with out of memory
messages. this in not unique to xl. i had the same probem with lotus. cut
seems to be worse that copy.
have you tried henry's suggestion?

FSt1

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub





  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

the problem now is that excel searches column 24 and finds every column since
I have "true" in the formulas... As I said... if I copy and paste values
over the entire column (24) then the code works.

My question is... "Is there anyway to tell excel to search for cell values
that equal true and not just "true" in the formula that is in each cell. For
example, =IF(E5=t0983101!$X$4,TRUE,FALSE)... this triggers the cut and paste
in the macro... even though the formula result of this cell is false.

Thanks again.

"FSt1" wrote:

hi
yes it seems to work fine but what is happening this the copy/paste uses the
clipboard and it eats up the memory. crash usually occurs with out of memory
messages. this in not unique to xl. i had the same probem with lotus. cut
seems to be worse that copy.
have you tried henry's suggestion?

FSt1

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Endless loop?

apologies if what I am refering to in the copy and paste... here is the
slightly modified code... I am copying and pasting column 24 to get values
into that column...

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("x6").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
firstadd = rngFound
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

"John" wrote:

the problem now is that excel searches column 24 and finds every column since
I have "true" in the formulas... As I said... if I copy and paste values
over the entire column (24) then the code works.

My question is... "Is there anyway to tell excel to search for cell values
that equal true and not just "true" in the formula that is in each cell. For
example, =IF(E5=t0983101!$X$4,TRUE,FALSE)... this triggers the cut and paste
in the macro... even though the formula result of this cell is false.

Thanks again.

"FSt1" wrote:

hi
yes it seems to work fine but what is happening this the copy/paste uses the
clipboard and it eats up the memory. crash usually occurs with out of memory
messages. this in not unique to xl. i had the same probem with lotus. cut
seems to be worse that copy.
have you tried henry's suggestion?

FSt1

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Endless loop?

john,
I have to go do my end of day stuff. Steve has the solution i think. if i
can't get back today, post again tomorrow and i will get back with you on
this thread.

Sorry i have to leave.
regards
FSt2
"John" wrote:

the problem now is that excel searches column 24 and finds every column since
I have "true" in the formulas... As I said... if I copy and paste values
over the entire column (24) then the code works.

My question is... "Is there anyway to tell excel to search for cell values
that equal true and not just "true" in the formula that is in each cell. For
example, =IF(E5=t0983101!$X$4,TRUE,FALSE)... this triggers the cut and paste
in the macro... even though the formula result of this cell is false.

Thanks again.

"FSt1" wrote:

hi
yes it seems to work fine but what is happening this the copy/paste uses the
clipboard and it eats up the memory. crash usually occurs with out of memory
messages. this in not unique to xl. i had the same probem with lotus. cut
seems to be worse that copy.
have you tried henry's suggestion?

FSt1

"John" wrote:

If I copy and paste values in my formula (true/false) column it all works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the macro.
it has been my experience that the cut and copy commands should not be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes my
excel... have I set up an endless loop? The idea is that if a certian column
in the sheet equals "true" then cut that row and paste it into a new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub



  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default Endless loop?

Found this little trick when using find:

Selection.Find(What:="true", After:=ActiveCell, LookIn:=xlValues, LookAt
_
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False).Activate

The trick comes by using: LookIn:=xlValues
Only picked cells that returned TRUE... Ignored cells that returned FALSE.
--
steveB

Remove "AYN" from email to respond
"John" wrote in message
...
the problem now is that excel searches column 24 and finds every column
since
I have "true" in the formulas... As I said... if I copy and paste values
over the entire column (24) then the code works.

My question is... "Is there anyway to tell excel to search for cell values
that equal true and not just "true" in the formula that is in each cell.
For
example, =IF(E5=t0983101!$X$4,TRUE,FALSE)... this triggers the cut and
paste
in the macro... even though the formula result of this cell is false.

Thanks again.

"FSt1" wrote:

hi
yes it seems to work fine but what is happening this the copy/paste uses
the
clipboard and it eats up the memory. crash usually occurs with out of
memory
messages. this in not unique to xl. i had the same probem with lotus. cut
seems to be worse that copy.
have you tried henry's suggestion?

FSt1

"John" wrote:

If I copy and paste values in my formula (true/false) column it all
works
fine... again assuming a smaller sample size...

"FSt1" wrote:

hi,
i think it is the cut/copy part of your do loop that is crashing the
macro.
it has been my experience that the cut and copy commands should not
be used
in a macro excessively. once or twice is ok but with inside a loop, i
wouldn't have done it that way.
you can add this just before the cut command.

Application.CutCopyMode = False

that will clear the clipboard.
if that don't work then you will have to use another way. maybe with
variable. post back if it don't work and is before 4:00Pm EDT US.

regards

FSt1


"John" wrote:

I have a piece of code that I am experimenting with and it crashes
my
excel... have I set up an endless loop? The idea is that if a
certian column
in the sheet equals "true" then cut that row and paste it into a
new sheet.

Thanks for the help!

Sub NI()
'

'
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Sheets("t0983101").Select
Range("E4").Select
Range(Selection, Selection.End(xlDown)).Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A4").Select
Dim rngToSearch As Range
Dim wks As Worksheet
Dim rngFound As Range

Set wks = Sheets("t0983101")
Set rngToSearch = wks.Columns(24)

Set rngFound = rngToSearch.Find("true")
If rngFound Is Nothing Then
MsgBox "No NI Trades Found"
Else
Do
rngFound.EntireRow.Cut
Sheets("NI").Select
Range("A9").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveSheet.Paste
Set rngFound = rngToSearch.FindNext
Loop Until rngFound Is Nothing
End If
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub





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
Endless spreadsheet calculations Zsolt Szabó Excel Discussion (Misc queries) 0 September 22nd 09 03:22 AM
file won't open, endless loop, autorecover lindalou Excel Discussion (Misc queries) 1 January 20th 08 01:26 AM
deleting rows, endless loop maybe ? dick[_2_] Excel Programming 3 June 28th 05 06:35 PM
Interrupting an endless loop davegb Excel Programming 3 March 17th 05 05:06 PM
Endless Loop when using ComboBox1.BoundColumn = 2 shrekut Excel Programming 2 January 12th 04 01:46 PM


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