Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cut a range between 2 cells containing found data

I normally can get to where I want with Excel VBA code but I have hit
the wall with this one and can't find a solution.

I have a list in Excel which contains 5 distinct ranges of
information. I want to split these 5 ranges and cut/copy to 5 separate
sheets. The actual moving of the data etc is not the problem. The
problem that I can't solve is:

basically I want to: select and cut all the rows beginning with a row
containing a cell with certain text and ending with a
row containing a cell with another specified text. I need to do this
repeatedly, and the number of rows between these two finds differs and
will differ at different times I run this macro.

Does anybody have a code suggestion that will enable me to do this?

I have been trying with the following:

Sub Range()
Range(Cells.Find("Air Jack System"), Cells.Find("Air Jack
System")).EntireRange.Cut
End Sub

But, I keep getting errors and it just wont work.

Any help or suggestions will be greatly appreciated. I hope this makes
sense. If not I will try to clarify it.

Many Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Cut a range between 2 cells containing found data

Don't call a procedure Range, you will make the Range object error out.

Sub Ranges()
Dim rngStart As Range
Dim rngEnd As Range
Dim sFirst As String
Set rngStart = Cells.Find(What:="Air Jack System", _
Lookat:=xlWhole)
If rngStart Is Nothing Then
MsgBox "Start value not found)"
Else
sFirst = rngStart.Address
Set rngEnd = Cells.FindNext(rngStart)
If rngEnd Is Nothing Or sFirst = rngEnd.Address Then
MsgBox "End value not found"
Else
Range(rngStart, rngEnd).Cut
End If
End If
End Sub

--
---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)



wrote in message
oups.com...
I normally can get to where I want with Excel VBA code but I have hit
the wall with this one and can't find a solution.

I have a list in Excel which contains 5 distinct ranges of
information. I want to split these 5 ranges and cut/copy to 5 separate
sheets. The actual moving of the data etc is not the problem. The
problem that I can't solve is:

basically I want to: select and cut all the rows beginning with a row
containing a cell with certain text and ending with a
row containing a cell with another specified text. I need to do this
repeatedly, and the number of rows between these two finds differs and
will differ at different times I run this macro.

Does anybody have a code suggestion that will enable me to do this?

I have been trying with the following:

Sub Range()
Range(Cells.Find("Air Jack System"), Cells.Find("Air Jack
System")).EntireRange.Cut
End Sub

But, I keep getting errors and it just wont work.

Any help or suggestions will be greatly appreciated. I hope this makes
sense. If not I will try to clarify it.

Many Thanks



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
Auto populate data from a table into cells after a match is found CrashOz Excel Worksheet Functions 5 January 15th 08 11:43 AM
When entering data into a range of cells, select the entire range. Q Excel Discussion (Misc queries) 0 September 26th 07 04:36 AM
Conditional format if cell match found in another range of cells Nolene Excel Worksheet Functions 2 October 5th 06 06:56 AM
Check if a value is found twice in a range François Excel Programming 3 May 13th 05 12:52 PM
Range Name Found?? Michael Kintner Excel Programming 2 January 6th 04 06:25 PM


All times are GMT +1. The time now is 08:00 AM.

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"