Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Move row to another worksheet

Thanks to Jim Thomlinson for the following code to move rows to another
worksheet.

This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is formulae
in column AV. Please help.

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete
End If
End Sub


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Move row to another worksheet

Hi Janelle

Are you saying the result of the formula in AV gives either "current" or
"non current" as its result?
If so, then just amend 1 line of Jim's code from
Set rngFound = rngToSearch.Find(What:="closed", _
to
Set rngFound = rngToSearch.Find(What:="non current", _

--
Regards
Roger Govier

"Janelle S" wrote in message
...
Thanks to Jim Thomlinson for the following code to move rows to another
worksheet.

This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is
calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is
formulae
in column AV. Please help.

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Move row to another worksheet

Thanks Roger

I changed the variable to read "non current" as suggested but I still get
the pop up msg ""There are no items to move." Any other suggestions?

"Roger Govier" wrote:

Hi Janelle

Are you saying the result of the formula in AV gives either "current" or
"non current" as its result?
If so, then just amend 1 line of Jim's code from
Set rngFound = rngToSearch.Find(What:="closed", _
to
Set rngFound = rngToSearch.Find(What:="non current", _

--
Regards
Roger Govier

"Janelle S" wrote in message
...
Thanks to Jim Thomlinson for the following code to move rows to another
worksheet.

This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is
calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is
formulae
in column AV. Please help.

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete
End If
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 26
Default Move row to another worksheet

I have solved my query thanks to Ron de Bruin's "Find value in Range, Sheet
or Sheets with VBA" tip sheet. What a great resource.

Replaced LookIn:=xlFormulas with LookIn:=xlValues

"Janelle S" wrote:

Thanks Roger

I changed the variable to read "non current" as suggested but I still get
the pop up msg ""There are no items to move." Any other suggestions?

"Roger Govier" wrote:

Hi Janelle

Are you saying the result of the formula in AV gives either "current" or
"non current" as its result?
If so, then just amend 1 line of Jim's code from
Set rngFound = rngToSearch.Find(What:="closed", _
to
Set rngFound = rngToSearch.Find(What:="non current", _

--
Regards
Roger Govier

"Janelle S" wrote in message
...
Thanks to Jim Thomlinson for the following code to move rows to another
worksheet.

This works perfectly where the value in column AV is text however what I
would like is for this column to be a formulae. This formulae is
calculated
on whether the case is closed and on date (giving "current"/"non current"
result). The code doesn't seem to recognise the results if there is
formulae
in column AV. Please help.

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete
End If
End Sub


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,480
Default Move row to another worksheet

Hi Janelle

Glad you got it resolved. Thanks for letting us know
thanks to Ron de Bruin's .... tip sheet. What a great resource

Yes, Ron's site is a wealth of information
--
Regards
Roger Govier

"Janelle S" wrote in message
...
I have solved my query thanks to Ron de Bruin's "Find value in Range,
Sheet
or Sheets with VBA" tip sheet. What a great resource.

Replaced LookIn:=xlFormulas with LookIn:=xlValues

"Janelle S" wrote:

Thanks Roger

I changed the variable to read "non current" as suggested but I still get
the pop up msg ""There are no items to move." Any other suggestions?

"Roger Govier" wrote:

Hi Janelle

Are you saying the result of the formula in AV gives either "current"
or
"non current" as its result?
If so, then just amend 1 line of Jim's code from
Set rngFound = rngToSearch.Find(What:="closed", _
to
Set rngFound = rngToSearch.Find(What:="non current", _

--
Regards
Roger Govier

"Janelle S" wrote in message
...
Thanks to Jim Thomlinson for the following code to move rows to
another
worksheet.

This works perfectly where the value in column AV is text however
what I
would like is for this column to be a formulae. This formulae is
calculated
on whether the case is closed and on date (giving "current"/"non
current"
result). The code doesn't seem to recognise the results if there is
formulae
in column AV. Please help.

Sub MoveStuff()
Dim rngToSearch As Range
Dim rngFound As Range
Dim rngFoundAll As Range
Dim rngPaste As Range
Dim strFirstAddress As String

Set rngPaste = Sheets("_Non Current").Cells(Rows.Count, _
"A").End(xlUp).Offset(1, 0)
Set rngToSearch = ActiveSheet.Columns("AV")
Set rngFound = rngToSearch.Find(What:="closed", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)
If rngFound Is Nothing Then
MsgBox "There are no items to move."
Else
Set rngFoundAll = rngFound
strFirstAddress = rngFound.Address
Do
Set rngFoundAll = Union(rngFound, rngFoundAll)
Set rngFound = rngToSearch.FindNext(rngFound)
Loop Until rngFound.Address = strFirstAddress

rngFoundAll.EntireRow.Copy Destination:=rngPaste
rngFoundAll.EntireRow.Delete
End If
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
HOW WILL MOVE TO 2ND WORKSHEET [email protected] Excel Worksheet Functions 2 November 22nd 07 08:57 AM
How to move from one Worksheet to another. Don J Excel Discussion (Misc queries) 3 February 20th 07 09:18 PM
Unable to Insert Worksheet/Move and copy worksheet Excel 2003 lukerush Excel Worksheet Functions 2 September 7th 06 05:05 PM
How do I move data from one worksheet to another? Intrepid_firefighter Excel Discussion (Misc queries) 1 July 22nd 06 08:58 AM
How to move to the next worksheet if its protect stbrown22 Excel Discussion (Misc queries) 0 February 3rd 06 05:55 PM


All times are GMT +1. The time now is 09:12 AM.

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"