Go Premium for a chance to win a PS4. Enter to Win

x
?
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
Medium Priority
?
176 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 42

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 46

Accepted Solution

by:
aikimark earned 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This article describes how you can use Custom Document Properties to store settings and other information in your workbook so that they will be available the next time you open the workbook.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

971 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