Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Lopp in column to find and select

Looking for a code which would loop in a column to find and select what
is in my active cell.

Eg: Activecell : B5 = "Test"

B6 & B7 also contains "Test"

How can I loop in column B to find & select all 3 cells.

Thxs

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Lopp in column to find and select

Hi Al007,

Try:

'=============
Public Sub Tester1A()
Dim rng As Range
Dim rngFound As Range
Dim rngOut As Range
Dim sStr As String
Dim firstAdd As String

Set rng = ActiveCell
sStr = rng.Value

Set rngFound = rng.EntireColumn.Find _
(What:=sStr, _
After:=rng(1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext)

If Not rngFound Is Nothing Then
firstAdd = rngFound.Address
Set rngOut = rngFound
End If

Do
Set rngFound = rng.EntireColumn.FindNext(rngFound)
If Not rngFound Is Nothing Then
Set rngOut = Union(rngOut, rngFound)
End If
Loop While Not rngFound Is Nothing _
And rngFound.Address < firstAdd


If Not rngOut Is Nothing Then rngOut.Select

End Sub
'<<=============

This is an adaptation of the example code provided by VBA help.


---
Regards,
Norman


"al007" wrote in message
oups.com...
Looking for a code which would loop in a column to find and select what
is in my active cell.

Eg: Activecell : B5 = "Test"

B6 & B7 also contains "Test"

How can I loop in column B to find & select all 3 cells.

Thxs



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Lopp in column to find and select

thxs a lot for your help !!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Lopp in column to find and select


While i am deciphering the code below, may i know if you also could help
with my scenario.

Given: A robust worksheet with almost 10,000 rows.

Column A could have the same entries.
ig A1= Apple; A2= Apple
If this is the case, then the row of A2 must be deleted.

We are aiming to have a file whose Column A entries are unique from each
other.


Please help...
Thank you for your immediate consideration.

Happy New Year!


"Norman Jones" wrote:

Hi Al007,

Try:

'=============
Public Sub Tester1A()
Dim rng As Range
Dim rngFound As Range
Dim rngOut As Range
Dim sStr As String
Dim firstAdd As String

Set rng = ActiveCell
sStr = rng.Value

Set rngFound = rng.EntireColumn.Find _
(What:=sStr, _
After:=rng(1), _
LookIn:=xlValues, _
LookAt:=xlPart, _
SearchOrder:=xlByColumns, _
SearchDirection:=xlNext)

If Not rngFound Is Nothing Then
firstAdd = rngFound.Address
Set rngOut = rngFound
End If

Do
Set rngFound = rng.EntireColumn.FindNext(rngFound)
If Not rngFound Is Nothing Then
Set rngOut = Union(rngOut, rngFound)
End If
Loop While Not rngFound Is Nothing _
And rngFound.Address < firstAdd


If Not rngOut Is Nothing Then rngOut.Select

End Sub
'<<=============

This is an adaptation of the example code provided by VBA help.


---
Regards,
Norman


"al007" wrote in message
oups.com...
Looking for a code which would loop in a column to find and select what
is in my active cell.

Eg: Activecell : B5 = "Test"

B6 & B7 also contains "Test"

How can I loop in column B to find & select all 3 cells.

Thxs




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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Find something in column a then find if column B matches criteria Darrell_Sarrasin via OfficeKB.com Excel Discussion (Misc queries) 8 November 28th 07 09:40 PM
Shortcut to select column with data in previous column TJAC Excel Discussion (Misc queries) 1 July 10th 07 06:12 PM
Find Last Column, Select, and Bold Yellowbird Excel Programming 5 June 24th 04 04:59 PM
How to find a value then select that column Sevcav Excel Programming 1 November 5th 03 02:18 AM


All times are GMT +1. The time now is 12:15 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"