Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Find and Select

I have the following list of data in column A:
1
2
1
3
1
4
1
5
1
6

The following code will select the values that I want (the value 1):
Sub SELECTVALUES()
Dim c As Range
Dim d As Range
Dim FirstAddress As String
Dim myFindString As String
myFindString = "1"
With ActiveSheet.Range("A:A")
Set c = .Find(myFindString, LookIn:=xlValues, lookAt:=xlWhole)
If Not c Is Nothing Then
Set d = c
FirstAddress = c.Address
End If
Set c = .FindNext(c)
If Not c Is Nothing And c.Address < FirstAddress Then
Do
Set d = Union(d, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With

d.Select

End Sub

I need help adjusting the code to select the data that is in the same row as
the found value in columns B,C and D instead of column A.

Any help would be appreciated. Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 123
Default Find and Select


Not sure what you are up to but try below code:

Sub whatEver()
Dim c, myRange As Range, firstAddr As String
For Each c In ActiveSheet.UsedRange
If c.Value = 1 Then
Set myRange = c
firstAddr = c.Address
Exit For
End If
Next c

For Each c In ActiveSheet.UsedRange
If c.Value = 1 And Not c.Address = firstAddr Then
Set myRange = Union(myRange, c)
End If
Next c
myRange.Select
End Sub

Sharad

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Find and Select

Hi Judd,

Will change the code

"A:A"

to

ActiveCell.EntireColumn

works? Of course, you have to place the cell pointer to the column you want
to do the job.

Frederick Chow
Hong Kong.


"Judd Jones" wrote in message
...
I have the following list of data in column A:
1
2
1
3
1
4
1
5
1
6

The following code will select the values that I want (the value 1):
Sub SELECTVALUES()
Dim c As Range
Dim d As Range
Dim FirstAddress As String
Dim myFindString As String
myFindString = "1"
With ActiveSheet.Range("A:A")
Set c = .Find(myFindString, LookIn:=xlValues, lookAt:=xlWhole)
If Not c Is Nothing Then
Set d = c
FirstAddress = c.Address
End If
Set c = .FindNext(c)
If Not c Is Nothing And c.Address < FirstAddress Then
Do
Set d = Union(d, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < FirstAddress
End If
End With

d.Select

End Sub

I need help adjusting the code to select the data that is in the same row
as
the found value in columns B,C and D instead of column A.

Any help would be appreciated. Thanks.



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
Find & Select Celeste[_2_] Excel Discussion (Misc queries) 3 December 1st 09 05:52 PM
find & select Aaron Hodson \(Coversure\) Excel Worksheet Functions 2 August 21st 08 08:36 AM
find and Select cells Richard Excel Discussion (Misc queries) 1 June 23rd 06 12:00 PM
Find All.... Then Select All Jason Excel Programming 2 November 7th 04 07:52 PM
Find then select to the right JUAN Excel Programming 2 April 30th 04 09:49 PM


All times are GMT +1. The time now is 01:27 AM.

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

About Us

"It's about Microsoft Excel"