Results 1 to 10 of 12

Thread: Macro to copy data containing numeric values

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Excel Fox's Avatar
    Join Date
    Mar 2011
    Posts
    1,401
    Rep Power
    10
    Try this

    Code:
    Sub ExcelFox()
    
        Dim rng As Range
        Dim rngEach As Range
        With Worksheets("Sheet1")
            Set rng = .Range("K2", .Cells(.Rows.Count, "K").End(xlUp))
        End With
        For Each rngEach In rng
            If HasNumber(rngEach.Value) Then
                rngEach(, 0).Value = rngEach.Value
            End If
        Next rngEach
    End Sub
    
    Private Function HasNumber(varValue As Variant) As Boolean
    
        HasNumber = Evaluate("MAX(IFERROR(FIND({""0"",""1"",""2"",""4"",""5"",""6"",""7"",""8"",""9""},""" & varValue & """),0))")
        
    End Function
    A dream is not something you see when you are asleep, but something you strive for when you are awake.

    It's usually a bad idea to say that something can't be done.

    The difference between dream and aim, is that one requires soundless sleep to see and the other requires sleepless efforts to achieve

    Join us at Facebook

  2. #2
    Member
    Join Date
    Aug 2012
    Posts
    40
    Rep Power
    0
    Hi Excel Fox

    Thanks it works perfectly

    Flupsie

Similar Threads

  1. Replies: 0
    Last Post: 04-20-2013, 10:07 AM
  2. Macro to copy data in specific Columns
    By Howardc in forum Excel Help
    Replies: 0
    Last Post: 04-19-2013, 10:42 AM
  3. Extracting Numeric Values From Alphanumeric Text
    By Safal Shrestha in forum Excel Help
    Replies: 3
    Last Post: 03-21-2013, 12:04 PM
  4. Macro to copy data from a set of excel files
    By Sreejesh Menon in forum Excel Help
    Replies: 5
    Last Post: 11-15-2012, 11:17 AM
  5. Replies: 2
    Last Post: 11-08-2012, 01:15 PM

Posting Permissions

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