PC Review


Reply
 
 
Sal
Guest
Posts: n/a
 
      28th May 2009
Every time Column I has “04” or “05” in a row, I would like to cut that
entire row Columns A:AH, create a new worksheet named “0405” , and paste
those cut rows into the new worksheet, so that the rows do not overlap.

Here is what I have so far. Any help would be appreciated.

Sub Capture0405()

Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
newsht.Name = "0405"
End Sub

 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      28th May 2009

Sub Capture0405()

set oldsht = activesheet
Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
newsht.Name = "0405"

NewRow = 1
with oldsht
OldRow = 1
do while .Range("I" & OldRow) <> ""
if .Range("I" & OldRow) = 4 or _
.Range("I" & OldRow) = 5 then
.Range("A" & OldRow & ":H" & OldRow).copy _
Destination:=NewSht.Range("A" & Newrow)
NewRow = NewRow + 1
end if
OldRow = OldRow + 1
Loop
End Sub


"Sal" wrote:

> Every time Column I has “04” or “05” in a row, I would like to cut that
> entire row Columns A:AH, create a new worksheet named “0405” , and paste
> those cut rows into the new worksheet, so that the rows do not overlap.
>
> Here is what I have so far. Any help would be appreciated.
>
> Sub Capture0405()
>
> Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
> newsht.Name = "0405"
> End Sub
>

 
Reply With Quote
 
Chip Pearson
Guest
Posts: n/a
 
      28th May 2009

Try code like the following. It will create the sheet "0405" if it
doesn't exist.

Sub AAA()

Dim LastRow As Long
Dim RowNdx As Long
Dim SourceWS As Worksheet
Dim DestWS As Worksheet
Dim Dest As Range
Dim DeleteThese As Range
Dim R As Range

Set SourceWS = Worksheets("Sheet1") '<<< Change
On Error Resume Next
Set DestWS = Worksheets("0405")
If DestWS Is Nothing Then
' doesn't exist. create it.
With ThisWorkbook.Worksheets
Set DestWS = .Add(after:=.Item(.Count))
DestWS.Name = "0405"
End With
End If
With DestWS
Set Dest = .Cells(.Rows.Count, "A").End(xlUp)
If Dest.Value <> vbNullString Then
Set Dest = Dest(2, 1)
End If
End With
On Error GoTo 0
With SourceWS
LastRow = .Cells(.Rows.Count, "I").End(xlUp).Row
For RowNdx = 1 To LastRow
Set R = .Cells(RowNdx, "i")
Select Case R.Value
Case "04", "05"
If DeleteThese Is Nothing Then
Set DeleteThese = R.EntireRow
Else
Set DeleteThese = _
Application.Union(DeleteThese, R.EntireRow)
End If
R.EntireRow.Copy Destination:=Dest
Set Dest = Dest(2, 1)
Case Else
' do nothing
End Select
Next RowNdx
End With

If Not DeleteThese Is Nothing Then
DeleteThese.Delete
End If

End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)



On Thu, 28 May 2009 13:31:01 -0700, Sal
<(E-Mail Removed)> wrote:

>Every time Column I has 04 or 05 in a row, I would like to cut that
>entire row Columns A:AH, create a new worksheet named 0405 , and paste
>those cut rows into the new worksheet, so that the rows do not overlap.
>
>Here is what I have so far. Any help would be appreciated.
>
>Sub Capture0405()
>
>Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
> newsht.Name = "0405"
>End Sub

 
Reply With Quote
 
Sal
Guest
Posts: n/a
 
      30th May 2009
This is great. Thank you for the help.

"Joel" wrote:

>
> Sub Capture0405()
>
> set oldsht = activesheet
> Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
> newsht.Name = "0405"
>
> NewRow = 1
> with oldsht
> OldRow = 1
> do while .Range("I" & OldRow) <> ""
> if .Range("I" & OldRow) = 4 or _
> .Range("I" & OldRow) = 5 then
> .Range("A" & OldRow & ":H" & OldRow).copy _
> Destination:=NewSht.Range("A" & Newrow)
> NewRow = NewRow + 1
> end if
> OldRow = OldRow + 1
> Loop
> End Sub
>
>
> "Sal" wrote:
>
> > Every time Column I has “04” or “05” in a row, I would like to cut that
> > entire row Columns A:AH, create a new worksheet named “0405” , and paste
> > those cut rows into the new worksheet, so that the rows do not overlap.
> >
> > Here is what I have so far. Any help would be appreciated.
> >
> > Sub Capture0405()
> >
> > Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
> > newsht.Name = "0405"
> > End Sub
> >

 
Reply With Quote
 
Sal
Guest
Posts: n/a
 
      30th May 2009
Wow, I appreciate this very much. The macro works very well. Thank you for
the help.

"Chip Pearson" wrote:

>
> Try code like the following. It will create the sheet "0405" if it
> doesn't exist.
>
> Sub AAA()
>
> Dim LastRow As Long
> Dim RowNdx As Long
> Dim SourceWS As Worksheet
> Dim DestWS As Worksheet
> Dim Dest As Range
> Dim DeleteThese As Range
> Dim R As Range
>
> Set SourceWS = Worksheets("Sheet1") '<<< Change
> On Error Resume Next
> Set DestWS = Worksheets("0405")
> If DestWS Is Nothing Then
> ' doesn't exist. create it.
> With ThisWorkbook.Worksheets
> Set DestWS = .Add(after:=.Item(.Count))
> DestWS.Name = "0405"
> End With
> End If
> With DestWS
> Set Dest = .Cells(.Rows.Count, "A").End(xlUp)
> If Dest.Value <> vbNullString Then
> Set Dest = Dest(2, 1)
> End If
> End With
> On Error GoTo 0
> With SourceWS
> LastRow = .Cells(.Rows.Count, "I").End(xlUp).Row
> For RowNdx = 1 To LastRow
> Set R = .Cells(RowNdx, "i")
> Select Case R.Value
> Case "04", "05"
> If DeleteThese Is Nothing Then
> Set DeleteThese = R.EntireRow
> Else
> Set DeleteThese = _
> Application.Union(DeleteThese, R.EntireRow)
> End If
> R.EntireRow.Copy Destination:=Dest
> Set Dest = Dest(2, 1)
> Case Else
> ' do nothing
> End Select
> Next RowNdx
> End With
>
> If Not DeleteThese Is Nothing Then
> DeleteThese.Delete
> End If
>
> End Sub
>
>
> Cordially,
> Chip Pearson
> Microsoft Most Valuable Professional
> Excel Product Group, 1998 - 2009
> Pearson Software Consulting, LLC
> www.cpearson.com
> (email on web site)
>
>
>
> On Thu, 28 May 2009 13:31:01 -0700, Sal
> <(E-Mail Removed)> wrote:
>
> >Every time Column I has “04” or “05” in a row, I would like to cut that
> >entire row Columns A:AH, create a new worksheet named “0405” , and paste
> >those cut rows into the new worksheet, so that the rows do not overlap.
> >
> >Here is what I have so far. Any help would be appreciated.
> >
> >Sub Capture0405()
> >
> >Set newsht = Sheets.Add(after:=Sheets(Sheets.Count))
> > newsht.Name = "0405"
> >End Sub

>

 
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
Windows Deployment Services Capture Wizard, Image capture in WDS =?Utf-8?B?SmltIFByZW5kZXJnYXN0?= Windows XP Setup 1 18th May 2007 10:23 AM
Any free and lite capture software to use with TV Wonder 650 to capture old video cassettes? Jone ATI Video Cards 1 8th May 2007 04:54 PM
Help Needed Adjusting Capture Brightness (Video Capture Device) =?Utf-8?B?QWxvaGFtaWtl?= Windows XP Video 1 24th Sep 2005 06:40 AM
TV capture card - criss-cross patterns on S-Video capture Peter Boulton Video Cards 0 25th May 2005 05:44 PM
video capture stops while trying to capture thru IEEE 1394 port AUZ Windows XP Video 2 1st May 2004 02:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:02 PM.