Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Moving a Selection of Data???

Hello,
Here is my set up. I have a sheet of data about 35,000 lines in in cloumn
"J" I would like to search for the text "Jump" in the entire column and when
I find it I want to copy that whole row of data along with the Heading &
format of the data sheet to a new sheet and name the sheet "Cause" and then
delete those rows from the data sheet.

Thanks,
Lime

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Moving a Selection of Data???


Hello Lime,

Here is a macro you can use to the job automatically. Add a VBA module
to your project and place this code in it. You can run the macro by
selecting it in the Macro list. Press ALT + F8 to bring up the dialog
in Excel or use the menu.


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

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress
Dim result As Range
Dim Wks

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(1).Range("J1:J35000")
Set result = .Find(2, lookin:=xlValues)
If Not result Is Nothing Then
firstAddress = result.Address
Do
If result.value = "Jump" Then

result.delete(xlShiftUp)
End If
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstAddress
End If
End With

End Sub

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


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=494370

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Moving a Selection of Data???

Thanks Leith, I'll give it a try, Thanks for your time.

Lime


"Leith Ross" wrote:


Hello Lime,

Here is a macro you can use to the job automatically. Add a VBA module
to your project and place this code in it. You can run the macro by
selecting it in the Macro list. Press ALT + F8 to bring up the dialog
in Excel or use the menu.


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

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress
Dim result As Range
Dim Wks

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(1).Range("J1:J35000")
Set result = .Find(2, lookin:=xlValues)
If Not result Is Nothing Then
firstAddress = result.Address
Do
If result.value = "Jump" Then

result.delete(xlShiftUp)
End If
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstAddress
End If
End With

End Sub

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


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=494370


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Moving a Selection of Data???

Hello,
All this does is add a sheet named Cause???

Lime

"Lime" wrote:

Thanks Leith, I'll give it a try, Thanks for your time.

Lime


"Leith Ross" wrote:


Hello Lime,

Here is a macro you can use to the job automatically. Add a VBA module
to your project and place this code in it. You can run the macro by
selecting it in the Macro list. Press ALT + F8 to bring up the dialog
in Excel or use the menu.


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

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress
Dim result As Range
Dim Wks

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(1).Range("J1:J35000")
Set result = .Find(2, lookin:=xlValues)
If Not result Is Nothing Then
firstAddress = result.Address
Do
If result.value = "Jump" Then

result.delete(xlShiftUp)
End If
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstAddress
End If
End With

End Sub

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


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=494370


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving a Selection of Data???

That won't work because when you delete the cells reference by Result, and
then try to use it again, you get an error. Also, It appears Leith forgot
to add the part to copy to the sheet Cause.

Untested,

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress as String
Dim result As Range
Dim Wks as Worksheet
Dim rng as Range

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(2).Range("J1:J35000")
.Rows(1).Copy Worksheets("Cause").Range("A1")
Set result = .Find("Jump", After:=Worksheets(1).Range("J1"), _
LookIn:=xlValues)
If Not result Is Nothing Then
firstaddress = result.Address
Do
if not rng is nothing then
set rng = Union(rng, result.EntireRow)
else
set rng = result.EntireRow
End if
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstaddress
End If
End With
If not rng is nothing then
rng.copy Destination:=Worksheets("Cause").Range("A2")
rng.Delete
End if
End Sub

The above worked for me.


--
Regards,
Tom Ogilvy


"Lime" wrote in message
...
Thanks Leith, I'll give it a try, Thanks for your time.

Lime


"Leith Ross" wrote:


Hello Lime,

Here is a macro you can use to the job automatically. Add a VBA module
to your project and place this code in it. You can run the macro by
selecting it in the Macro list. Press ALT + F8 to bring up the dialog
in Excel or use the menu.


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

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress
Dim result As Range
Dim Wks

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(1).Range("J1:J35000")
Set result = .Find(2, lookin:=xlValues)
If Not result Is Nothing Then
firstAddress = result.Address
Do
If result.value = "Jump" Then

result.delete(xlShiftUp)
End If
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstAddress
End If
End With

End Sub

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


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=494370






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Moving a Selection of Data???


With Worksheets(2).Range("J1:J35000")

change the 2 above to refer to the sheet containing Jump in column "J"

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote in message
...
That won't work because when you delete the cells reference by Result, and
then try to use it again, you get an error. Also, It appears Leith forgot
to add the part to copy to the sheet Cause.

Untested,

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress as String
Dim result As Range
Dim Wks as Worksheet
Dim rng as Range

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(2).Range("J1:J35000")
.Rows(1).Copy Worksheets("Cause").Range("A1")
Set result = .Find("Jump", After:=Worksheets(1).Range("J1"), _
LookIn:=xlValues)
If Not result Is Nothing Then
firstaddress = result.Address
Do
if not rng is nothing then
set rng = Union(rng, result.EntireRow)
else
set rng = result.EntireRow
End if
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstaddress
End If
End With
If not rng is nothing then
rng.copy Destination:=Worksheets("Cause").Range("A2")
rng.Delete
End if
End Sub

The above worked for me.


--
Regards,
Tom Ogilvy


"Lime" wrote in message
...
Thanks Leith, I'll give it a try, Thanks for your time.

Lime


"Leith Ross" wrote:


Hello Lime,

Here is a macro you can use to the job automatically. Add a VBA module
to your project and place this code in it. You can run the macro by
selecting it in the Macro list. Press ALT + F8 to bring up the dialog
in Excel or use the menu.


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

Sub FindJump()

Dim Exists As Boolean
Dim firstaddress
Dim result As Range
Dim Wks

For Each Wks In Worksheets
If Wks.Name = "Cause" Then Exists = True
Next Wks

If Not Exists Then
Worksheets.Add
ActiveSheet.Name = "Cause"
End If

With Worksheets(1).Range("J1:J35000")
Set result = .Find(2, lookin:=xlValues)
If Not result Is Nothing Then
firstAddress = result.Address
Do
If result.value = "Jump" Then

result.delete(xlShiftUp)
End If
Set result = .FindNext(result)
Loop While Not result Is Nothing And result.Address < firstAddress
End If
End With

End Sub

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


Sincerely,
Leith Ross


--
Leith Ross


------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread:

http://www.excelforum.com/showthread...hreadid=494370






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
Moving selection right one column at a time: Is there a shortcut? RD[_2_] New Users to Excel 2 May 19th 09 05:39 PM
Moving a selection... [email protected] Excel Discussion (Misc queries) 3 July 20th 06 04:50 PM
using a selection box and moving the accepted data madsenfence Excel Worksheet Functions 1 January 19th 06 03:42 AM
Moving Range Selection Right One Column at a Time TexDad Excel Programming 2 December 17th 05 07:25 PM
Moving a Selection of data??? Lime Excel Worksheet Functions 3 December 17th 05 06:55 PM


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