PC Review


Reply
Thread Tools Rate Thread

Change ws designator

 
 
=?Utf-8?B?SmVycnkgRm9sZXk=?=
Guest
Posts: n/a
 
      16th Apr 2007
Hello, Given the following macro:
Sub mastertest()

Dim ws As Worksheet, cell As Range, rng As Range

For Each ws In ThisWorkbook.Worksheets
If Not ws.Name = "Sheet2" Then
For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
If IsNumeric(cell) = True Then
cell.EntireRow.Copy _
Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
End If
Next cell
End If

Next ws

End Sub

How do I edit it to only seach col D only in the spreadsheet tab "New IP
Office" and write the results in Sheet2?

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      16th Apr 2007
set ws = worksheets("new ip office")
For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
If IsNumeric(cell) = True Then
cell.EntireRow.Copy _
Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
End If
Next cell



Jerry Foley wrote:
>
> Hello, Given the following macro:
> Sub mastertest()
>
> Dim ws As Worksheet, cell As Range, rng As Range
>
> For Each ws In ThisWorkbook.Worksheets
> If Not ws.Name = "Sheet2" Then
> For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> If IsNumeric(cell) = True Then
> cell.EntireRow.Copy _
> Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> End If
> Next cell
> End If
>
> Next ws
>
> End Sub
>
> How do I edit it to only seach col D only in the spreadsheet tab "New IP
> Office" and write the results in Sheet2?


--

Dave Peterson
 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      16th Apr 2007
One way:

Dim rSource As Range
Dim rDest As Range
Dim rCell As Range

On Error Resume Next
With ThisWorkbook.Sheets("New IP Office")
Set rSource = .Range(.Cells(1, 4), _
.Cells(.Rows.Count, 4).End(xlUp))
Set rDest = .Parent.Sheets("Sheet2").Cells( _
.Rows.Count, 1).End(xlUp).Offset(1, 0)
End With
On Error GoTo 0
If (Not rSource Is Nothing) And (Not rDest Is Nothing) Then
For Each rCell In rSource
With rCell
If IsNumeric(.Value) Then
.EntireRow.Copy Destination:=rDest
Set rDest = rDest.Offset(1, 0)
End If
End With
Next rCell
End If


In article <42FF284A-8968-4D08-910D-(E-Mail Removed)>,
Jerry Foley <(E-Mail Removed)> wrote:

> Hello, Given the following macro:
> Sub mastertest()
>
> Dim ws As Worksheet, cell As Range, rng As Range
>
> For Each ws In ThisWorkbook.Worksheets
> If Not ws.Name = "Sheet2" Then
> For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> If IsNumeric(cell) = True Then
> cell.EntireRow.Copy _
> Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> End If
> Next cell
> End If
>
> Next ws
>
> End Sub
>
> How do I edit it to only seach col D only in the spreadsheet tab "New IP
> Office" and write the results in Sheet2?

 
Reply With Quote
 
=?Utf-8?B?SmVycnkgRm9sZXk=?=
Guest
Posts: n/a
 
      16th Apr 2007
Thanks Dave. The only problem is that this macro only picks up the highest
numbered cell. it does not start at the top of the D col and scan all of the
cells down to find if there are any values. Any ideas?

"Dave Peterson" wrote:

> set ws = worksheets("new ip office")
> For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> If IsNumeric(cell) = True Then
> cell.EntireRow.Copy _
> Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> End If
> Next cell
>
>
>
> Jerry Foley wrote:
> >
> > Hello, Given the following macro:
> > Sub mastertest()
> >
> > Dim ws As Worksheet, cell As Range, rng As Range
> >
> > For Each ws In ThisWorkbook.Worksheets
> > If Not ws.Name = "Sheet2" Then
> > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > If IsNumeric(cell) = True Then
> > cell.EntireRow.Copy _
> > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > End If
> > Next cell
> > End If
> >
> > Next ws
> >
> > End Sub
> >
> > How do I edit it to only seach col D only in the spreadsheet tab "New IP
> > Office" and write the results in Sheet2?

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
=?Utf-8?B?SmVycnkgRm9sZXk=?=
Guest
Posts: n/a
 
      16th Apr 2007
Thanks...This macro finds the first value in col D and the last however it
also copies all of the blank cells in between the first and last value of the
col. Can that be fixed?

"JE McGimpsey" wrote:

> One way:
>
> Dim rSource As Range
> Dim rDest As Range
> Dim rCell As Range
>
> On Error Resume Next
> With ThisWorkbook.Sheets("New IP Office")
> Set rSource = .Range(.Cells(1, 4), _
> .Cells(.Rows.Count, 4).End(xlUp))
> Set rDest = .Parent.Sheets("Sheet2").Cells( _
> .Rows.Count, 1).End(xlUp).Offset(1, 0)
> End With
> On Error GoTo 0
> If (Not rSource Is Nothing) And (Not rDest Is Nothing) Then
> For Each rCell In rSource
> With rCell
> If IsNumeric(.Value) Then
> .EntireRow.Copy Destination:=rDest
> Set rDest = rDest.Offset(1, 0)
> End If
> End With
> Next rCell
> End If
>
>
> In article <42FF284A-8968-4D08-910D-(E-Mail Removed)>,
> Jerry Foley <(E-Mail Removed)> wrote:
>
> > Hello, Given the following macro:
> > Sub mastertest()
> >
> > Dim ws As Worksheet, cell As Range, rng As Range
> >
> > For Each ws In ThisWorkbook.Worksheets
> > If Not ws.Name = "Sheet2" Then
> > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > If IsNumeric(cell) = True Then
> > cell.EntireRow.Copy _
> > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > End If
> > Next cell
> > End If
> >
> > Next ws
> >
> > End Sub
> >
> > How do I edit it to only seach col D only in the spreadsheet tab "New IP
> > Office" and write the results in Sheet2?

>

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      16th Apr 2007
One way:

Dim rSource As Range
Dim rDest As Range
Dim rCell As Range

On Error Resume Next
With ThisWorkbook.Sheets("New IP Office")
Set rSource = .Range(.Cells(1, 4), _
.Cells(.Rows.Count, 4).End(xlUp))
Set rDest = .Parent.Sheets("Sheet2").Cells( _
.Rows.Count, 1).End(xlUp).Offset(1, 0)
End With
On Error GoTo 0
If (Not rSource Is Nothing) And (Not rDest Is Nothing) Then
For Each rCell In rSource
With rCell
If Not IsEmpty(.Value) Then
If IsNumeric(.Value) Then
.EntireRow.Copy Destination:=rDest
Set rDest = rDest.Offset(1, 0)
End If
End If
End With
Next rCell
End If


In article <62EA5FFC-C4B9-4823-BCC7-(E-Mail Removed)>,
Jerry Foley <(E-Mail Removed)> wrote:

> Thanks...This macro finds the first value in col D and the last however it
> also copies all of the blank cells in between the first and last value of the
> col. Can that be fixed?

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Apr 2007
It looks at all the cells in D1(lastusedrowincolumnD).

I'm not sure why you say it only looks at the highest numbered cell.



Jerry Foley wrote:
>
> Thanks Dave. The only problem is that this macro only picks up the highest
> numbered cell. it does not start at the top of the D col and scan all of the
> cells down to find if there are any values. Any ideas?
>
> "Dave Peterson" wrote:
>
> > set ws = worksheets("new ip office")
> > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > If IsNumeric(cell) = True Then
> > cell.EntireRow.Copy _
> > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > End If
> > Next cell
> >
> >
> >
> > Jerry Foley wrote:
> > >
> > > Hello, Given the following macro:
> > > Sub mastertest()
> > >
> > > Dim ws As Worksheet, cell As Range, rng As Range
> > >
> > > For Each ws In ThisWorkbook.Worksheets
> > > If Not ws.Name = "Sheet2" Then
> > > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > > If IsNumeric(cell) = True Then
> > > cell.EntireRow.Copy _
> > > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > > End If
> > > Next cell
> > > End If
> > >
> > > Next ws
> > >
> > > End Sub
> > >
> > > How do I edit it to only seach col D only in the spreadsheet tab "New IP
> > > Office" and write the results in Sheet2?

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Apr 2007
Ps. JE gave you a way to avoid empty cells when checking isnumeric.

Another way is to use:

if application.isnumber(cell.value) then

The worksheet function =isnumber() is more strict.

Dave Peterson wrote:
>
> It looks at all the cells in D1(lastusedrowincolumnD).
>
> I'm not sure why you say it only looks at the highest numbered cell.
>
> Jerry Foley wrote:
> >
> > Thanks Dave. The only problem is that this macro only picks up the highest
> > numbered cell. it does not start at the top of the D col and scan all of the
> > cells down to find if there are any values. Any ideas?
> >
> > "Dave Peterson" wrote:
> >
> > > set ws = worksheets("new ip office")
> > > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > > If IsNumeric(cell) = True Then
> > > cell.EntireRow.Copy _
> > > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > > End If
> > > Next cell
> > >
> > >
> > >
> > > Jerry Foley wrote:
> > > >
> > > > Hello, Given the following macro:
> > > > Sub mastertest()
> > > >
> > > > Dim ws As Worksheet, cell As Range, rng As Range
> > > >
> > > > For Each ws In ThisWorkbook.Worksheets
> > > > If Not ws.Name = "Sheet2" Then
> > > > For Each cell In ws.Range("D1" & ws.Range("D65536").End(xlUp).Row)
> > > > If IsNumeric(cell) = True Then
> > > > cell.EntireRow.Copy _
> > > > Sheets("Sheet2").Range("A65536").End(xlUp).Offset(1, 0)
> > > > End If
> > > > Next cell
> > > > End If
> > > >
> > > > Next ws
> > > >
> > > > End Sub
> > > >
> > > > How do I edit it to only seach col D only in the spreadsheet tab "New IP
> > > > Office" and write the results in Sheet2?
> > >
> > > --
> > >
> > > Dave Peterson
> > >

>
> --
>
> Dave Peterson


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?SmVycnkgRm9sZXk=?=
Guest
Posts: n/a
 
      16th Apr 2007
Thanks much...it works great. One last question...How can I specify for the
rows being copied to sheet2 to start at row 12 of sheet2.

i appreaciate yor help.

"JE McGimpsey" wrote:

> One way:
>
> Dim rSource As Range
> Dim rDest As Range
> Dim rCell As Range
>
> On Error Resume Next
> With ThisWorkbook.Sheets("New IP Office")
> Set rSource = .Range(.Cells(1, 4), _
> .Cells(.Rows.Count, 4).End(xlUp))
> Set rDest = .Parent.Sheets("Sheet2").Cells( _
> .Rows.Count, 1).End(xlUp).Offset(1, 0)
> End With
> On Error GoTo 0
> If (Not rSource Is Nothing) And (Not rDest Is Nothing) Then
> For Each rCell In rSource
> With rCell
> If Not IsEmpty(.Value) Then
> If IsNumeric(.Value) Then
> .EntireRow.Copy Destination:=rDest
> Set rDest = rDest.Offset(1, 0)
> End If
> End If
> End With
> Next rCell
> End If
>
>
> In article <62EA5FFC-C4B9-4823-BCC7-(E-Mail Removed)>,
> Jerry Foley <(E-Mail Removed)> wrote:
>
> > Thanks...This macro finds the first value in col D and the last however it
> > also copies all of the blank cells in between the first and last value of the
> > col. Can that be fixed?

>

 
Reply With Quote
 
JE McGimpsey
Guest
Posts: n/a
 
      17th Apr 2007
One way:

Change

Set rDest = .Parent.Sheets("Sheet2").Cells( _
.Rows.Count, 1).End(xlUp).Offset(1, 0)

to

Set rDest = .Parent.Sheets("Sheet2").Cells(12, 1)



In article <E52ACF00-EEB4-45DF-81C1-(E-Mail Removed)>,
Jerry Foley <(E-Mail Removed)> wrote:

> Thanks much...it works great. One last question...How can I specify for the
> rows being copied to sheet2 to start at row 12 of sheet2.

 
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
Display ID & Designator MackBlale Microsoft Access Queries 1 5th Jan 2009 05:46 AM
Alt Designator For AutoKeys jutlaux Microsoft Access VBA Modules 1 13th Nov 2008 11:11 PM
How do I change my column designator from Numeric to Alpha? Jon Microsoft Excel Setup 1 30th May 2008 08:59 PM
Change CD drive designator from D to another letter =?Utf-8?B?Smlt?= Windows XP Help 1 9th Jun 2004 11:18 PM
Re: How do U chg the year designator in a 14 digit number? Ken Wright Microsoft Excel Misc 5 5th Sep 2003 11:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:36 AM.