Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Finding a cell with 2 conditions


Hi,

Trying to write a macro which finds the text "Job No" and if it has
colorindex = 37 then assigns the column number of "Job No" to the
variable m

Below isnt quite working:


Sub fi()

taz = Cells.Find(What:="Job No", After:=ActiveCell, LookIn:=xlFormulas
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext
MatchCase:= _
False, SearchFormat:=False).Activate


If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If

End Su

--
T De Villier
-----------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...fo&userid=2647
View this thread: http://www.excelforum.com/showthread.php?threadid=56599

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 644
Default Finding a cell with 2 conditions

And by "isnt quite working" you mean what exactly?

Die_Another_Day
T De Villiers wrote:
Hi,

Trying to write a macro which finds the text "Job No" and if it has
colorindex = 37 then assigns the column number of "Job No" to the
variable m

Below isnt quite working:


Sub fi()

taz = Cells.Find(What:="Job No", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If

End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565990


  #3   Report Post  
Posted to microsoft.public.excel.programming
Les Les is offline
external usenet poster
 
Posts: 240
Default Finding a cell with 2 conditions

Try this, its a little simpler:

Dim taz As Range

Set taz = Cells.Find(What:="Job No")

If taz Is Nothing Then
'do nothing
Else
If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If
End If


--
Les Torchia-Wells


"T De Villiers" wrote:


Hi,

Trying to write a macro which finds the text "Job No" and if it has
colorindex = 37 then assigns the column number of "Job No" to the
variable m

Below isnt quite working:


Sub fi()

taz = Cells.Find(What:="Job No", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If

End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565990


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Finding a cell with 2 conditions

Sub fi()
Dim taz as Range
set taz = Cells.Find(What:="Job No", _
After:=ActiveCell, LookIn:=xlFormulas,
LookAt:=xlPart, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False)
if taz is nothing then
msgbox "Job No not found"
exit sub
else

If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If
End if
End Sub

--
Regards,
Tom Ogilvy

"T De Villiers" wrote:


Hi,

Trying to write a macro which finds the text "Job No" and if it has
colorindex = 37 then assigns the column number of "Job No" to the
variable m

Below isnt quite working:


Sub fi()

taz = Cells.Find(What:="Job No", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If

End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565990


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Finding a cell with 2 conditions

Just a thought for the OP:
since FIND has persistent properties that can cause inconsistent
performance, it is usually best to specify all properties. I doubt Les was
suggesting that you should not do this but only provided a simplified example
for expediency.

--
Regards,
Tom Ogilvy

"Les" wrote:

Try this, its a little simpler:

Dim taz As Range

Set taz = Cells.Find(What:="Job No")

If taz Is Nothing Then
'do nothing
Else
If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If
End If


--
Les Torchia-Wells


"T De Villiers" wrote:


Hi,

Trying to write a macro which finds the text "Job No" and if it has
colorindex = 37 then assigns the column number of "Job No" to the
variable m

Below isnt quite working:


Sub fi()

taz = Cells.Find(What:="Job No", After:=ActiveCell, LookIn:=xlFormulas,
LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:= _
False, SearchFormat:=False).Activate


If taz.Interior.ColorIndex = 37 Then
m = taz.Column
End If

End Sub


--
T De Villiers
------------------------------------------------------------------------
T De Villiers's Profile: http://www.excelforum.com/member.php...o&userid=26479
View this thread: http://www.excelforum.com/showthread...hreadid=565990


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
if conditions in 2 cell correct then display third cell Paul Hood New Users to Excel 3 January 21st 09 07:30 AM
Finding the average using conditions in a logic function - problem Thomas Excel Discussion (Misc queries) 1 August 1st 08 04:18 PM
Countif Conditions - Use of conditions that vary by cell value JonTarg Excel Discussion (Misc queries) 1 May 30th 08 01:21 PM
How do I make a cell refrence another cell based on conditions? Carl Excel Worksheet Functions 1 April 27th 08 03:05 PM
Conditional formatting Based on cell A text with conditions in Cell B Raicomm Excel Discussion (Misc queries) 0 January 21st 08 04:46 PM


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