PDA

View Full Version : Solved: Pickup numeric data only.



countryfan_n
03-09-2008, 02:30 AM
Hello friends,

Please help me, the below code picks up data once the condition is met, trouble is it is picking up text also, i only want it to pick the numeric data.
please see the bolded part

Ofcourse thanks in advance,
Nawaf


Sub ACTIVE()
Dim ii As Integer
Dim CW As Worksheet 'consolidation worksheet

Set CW = Sheets("ACL")
Const FC As Integer = 3 'first column
Const LC As Integer = 18 'last column

For Each cell In Sheets("WS").Range(Sheets("WS").[A14], Sheets("WS").[A65536].End(xlUp))
With Sheets(cell.Value)

For I = 2 To 1000
If .Cells(I, 13) > 0 Then
.Range(.Cells(I, FC), .Cells(I, LC)).Copy
CW.Cells(16, FC).Offset(ii).PasteSpecial xlValues
Application.CutCopyMode = False
CW.Cells(16, "T").Offset(ii) = .Cells(2, "O")
CW.Cells(16, "S").Offset(ii) = .Cells(4, "O")
ii = ii + 1
End If
Next I
End With
Next
End Sub

Bob Phillips
03-09-2008, 02:43 AM
Maybe



For I = 2 To 1000
If IsNumeric(.Cells(I, 13).Value) Then
If .Cells(I, 13).Value > 0 Then
.Range(.Cells(I, FC), .Cells(I, LC)).Copy
CW.Cells(16, FC).Offset(ii).PasteSpecial xlValues
Application.CutCopyMode = False
CW.Cells(16, "T").Offset(ii).Value = .Cells(2, "O").Value
CW.Cells(16, "S").Offset(ii).Value = .Cells(4, "O").Value
ii = ii + 1
endif
End If
Next I

Ru5ben
03-09-2008, 10:23 AM
Try the function IsNumeric()