Solved

how can i select cells with certain value in excel over numeric cells treating them as string values

Posted on 2012-03-16
3
165 Views
Last Modified: 2012-04-01
hi

i have an excel sheet with numeric values at  column D

i need to select rows who contain value 889490 at any record at column D

someone know how to do this via excel or vba?

thanks
MINUTA-2284820110311.xls
0
Comment
Question by:tenriquez199
3 Comments
 
LVL 41

Expert Comment

by:dlmille
ID: 37731480
Do you want to select them all at once?  You'll need to add a helper column to search by text.

E.g., column M2 and copy down:
[M2]=Text(D2,"0#")

Add column M to the filter, then search on contains 889490

See attached.

Dave
MINUTA-2284820110311.xls
0
 
LVL 18

Expert Comment

by:krishnakrkc
ID: 37732006
Hi

Or

in K2

=RIGHT(D2,6)="889490"

go to Data > Advanced Filter > Check on 'Filter the list, in place'

list range: A1:I827
criteria range: k1:k2

click ok.

Also see the attached image.

Kris
AdvFilter.JPG
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 37733414
This code will iterate the column D values and select the rows that meet the pattern you supply.

Option Explicit

Public Sub FilterNumberAsText(parmSearchForPattern As String)
    Dim wks As Worksheet
    Dim rng As Range
    Dim rngCell As Range
    Set wks = ActiveSheet
    For Each rngCell In wks.Range("D2", wks.Range("D2").End(xlDown))
        If rngCell.Value Like parmSearchForPattern Then
            If rng Is Nothing Then
                Set rng = rngCell.EntireRow
            Else
                Set rng = Union(rng, rngCell.EntireRow)
            End If
        End If
    Next
    rng.Select
End Sub

Open in new window


Here is an invocation of the routine, looking for the 889490 value at the end of the number.
FilterNumberAsText "*889490"

Open in new window


Here is an invocation of the routine, looking for the 889490 value anywhere in the number.
FilterNumberAsText "*889490*"

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
excel file 5 54
Visual Studio 2005 text editor 10 23
Excel 2016 Hiding Toolbars 7 23
Index Match not working on second pass 7 0
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now