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
174 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

622 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