ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Programming for column shift (https://www.excelbanter.com/excel-programming/383975-programming-column-shift.html)

Jerry Foley

Programming for column shift
 
Given the routine below, how can I have the macro seach column c of each
worksheet and if there is a numeric value in that cell copy the entire row to
another sheet (sheet2) and continue to search ?
Sub numbers()

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("A1:A" & ws.Range("A65536").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



Tim Williams

Programming for column shift
 

.....
If IsNumeric(cell.offset(0,2).value) Then
.....

The "=True" is not required here.

Or just change "A" to "C" in your for loop range.
--
Tim Williams
Palo Alto, CA


"Jerry Foley" wrote in message ...
Given the routine below, how can I have the macro seach column c of each
worksheet and if there is a numeric value in that cell copy the entire row to
another sheet (sheet2) and continue to search ?
Sub numbers()

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("A1:A" & ws.Range("A65536").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






All times are GMT +1. The time now is 01:43 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com