Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Select column by finding the text

Hello There,

I want to find a text in a sheet and then I want to select all the data in
that particular column. (note : In between the data blank cells are there.)

Thanks & Regards,

Sreenivas
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Select column by finding the text

Here is some code for you to try. This code looks for the Word "This"
anywhere on Sheet1 and selects all of the populated cells in that column...

Sub SelectColumn()
Dim rngFound As Range
Dim rngToSearch As Range
Dim rngFinal As Range
Dim wks As Worksheet

Set wks = Sheets("Sheet1")
Set rngToSearch = wks.Cells
Set rngFound = rngToSearch.Find(What:="This", _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
MatchCase:=False)

If rngFound Is Nothing Then
MsgBox "Sorry, Not found."
Else
Set rngToSearch = rngFound.EntireColumn
Set rngFound = rngToSearch.SpecialCells(xlCellTypeFormulas)
If Not rngFound Is Nothing Then
Set rngFinal = rngFound
End If
Set rngFound = rngToSearch.SpecialCells(xlCellTypeConstants)
If Not rngFound Is Nothing Then
Set rngFinal = Union(rngFound, rngFinal)
End If
rngFinal.Select
End If
End Sub
--
HTH...

Jim Thomlinson


"cheenu" wrote:

Hello There,

I want to find a text in a sheet and then I want to select all the data in
that particular column. (note : In between the data blank cells are there.)

Thanks & Regards,

Sreenivas

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you select all text/data within all the cells of a column? VisionsIC Excel Discussion (Misc queries) 3 December 20th 08 02:36 AM
Finding text in one column that compares to another Jim Jackson Excel Programming 9 January 7th 08 05:59 AM
Finding data in a text column Secret Squirrel Excel Discussion (Misc queries) 4 November 10th 07 05:23 PM
Finding Duplicate text strings with a single column Ed P Excel Worksheet Functions 2 March 17th 05 03:56 AM
Macro query - finding mutliple occurences of text in a column Mcneilius[_3_] Excel Programming 2 September 1st 04 08:00 PM


All times are GMT +1. The time now is 08:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"