+ Reply to Thread
Results 1 to 7 of 7

restrict collection to text values only

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    restrict collection to text values only

    I have a list of entries that contain many instances of both numeric and text value that I am trying to restrict to text only (I dont need and items beginning with a number). This code gives me an output in column H of unique entries.

    How can I use an If statement to filter only the entries starting with a letter??
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by nigelog; 05-24-2018 at 09:40 AM.

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: restrict collection to text values only

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: restrict collection to text values only

    Something like...
    Please Login or Register  to view this content.
    "Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something."
    ― Robert A. Heinlein

  4. #4
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,293

    Re: restrict collection to text values only

    Thanks Norie and CK76

    @Norie - spot on as usual, thanks

    @ CK76, unfortunately brought in other entries containing a letter

  5. #5
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,973

    Re: restrict collection to text values only

    Yes, didn't notice those items that didn't have " - " in string that started with numeric.

  6. #6
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Give it a try !


    Another way :

    PHP Code: 
    Sub Demo1()
                
    Dim V
        With Sheet1
                
    .Cells(8).CurrentRegion.Offset(1).Clear
                Application
    .ScreenUpdating False
            
    For Each V In .Range("A2", .Cells(1).End(xlDown)).Value
                
    If V Like "[A-Z]*" Then
                    With 
    .Cells(8).CurrentRegion
                        
    If IsError(Application.Match(V, .Cells0)) Then .Cells(.Rows.Count 11).Value V
                    End With
                End 
    If
            
    Next
        End With
                Application
    .ScreenUpdating True
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  7. #7
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool


    Or via an easy advanced filter :

    PHP Code: 
    Sub Demo2()
        
    Dim V
        With Sheet1
            V 
    = .Cells(8).Value
            
    .Cells(1).Copy .Cells(8)
            .[
    C2].Formula "=ISERR(VALUE(LEFT(A2)))"
            
    .Cells(1).CurrentRegion.AdvancedFilter xlFilterCopy, .[C1:C2], .Cells(8), True
            
    .Cells(8).Value V
        End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] The collection of values during the filtration
    By mido21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2017, 12:03 PM
  2. Replies: 4
    Last Post: 10-30-2015, 01:30 PM
  3. [SOLVED] Performance of iteration through Words collection degrades as collection gets bigger
    By 6StringJazzer in forum Word Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2014, 09:44 AM
  4. Restrict Text box Text to Actual Size of Text box
    By zhb12810 in forum Excel General
    Replies: 2
    Last Post: 10-07-2012, 03:54 AM
  5. Replies: 2
    Last Post: 12-23-2011, 11:04 AM
  6. Replies: 13
    Last Post: 08-17-2011, 02:16 PM
  7. Restrict text entry in textbox to JUST TEXT
    By TheNewGuy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-24-2009, 03:54 PM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1