PC Review


Reply
Thread Tools Rate Thread

Cut a range between 2 cells containing found data

 
 
T.Bell@hwaag.com
Guest
Posts: n/a
 
      22nd Feb 2007
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 With Quote
 
 
 
 
Bob Phillips
Guest
Posts: n/a
 
      22nd Feb 2007
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)



<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
highlight range, apply calculation to data in cells and paste special to same range S Himmelrich Microsoft Excel Discussion 2 6th Nov 2007 11:48 PM
When entering data into a range of cells, select the entire range. =?Utf-8?B?UQ==?= Microsoft Excel Misc 0 26th Sep 2007 04:36 AM
Conditional format if cell match found in another range of cells =?Utf-8?B?Tm9sZW5l?= Microsoft Excel Worksheet Functions 2 5th Oct 2006 06:56 AM
Count Empty Cells in Range After Cells with Data =?Utf-8?B?RGF2aWQ=?= Microsoft Excel Programming 16 17th Sep 2006 03:03 PM
MS Word: select cells range and duplicate same data in all cells =?Utf-8?B?Y2xhcmljZQ==?= Microsoft Word Document Management 0 1st Jun 2006 04:19 AM


Features
 

Advertising
 

Newsgroups
 


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