Consulting

Results 1 to 3 of 3

Thread: Solved: Pickup numeric data only.

  1. #1

    Solved: Pickup numeric data only.

    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

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Maybe

    [vba]

    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
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Try the function IsNumeric()

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •