Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Please help me find the problem with this

I have the following function:

Function MyRow(pattern As String)

oWB.Activate
oWS.Activate
Debug.Print "In MyRow function"
For i = 1 To 15
'Debug.Print i, Cells(i, "B").text, pattern
If Cells(i, "C").text Like pattern & "*" Then
MyRow = i
aWB.Activate
aWS.Activate
Debug.Print "MyRow = ", MyRow, Cells(i, "B").text, pattern
Exit Function
End If
Next i

End Function

I want to use it in the following formula

ActiveCell.FormulaR1C1 = _
"=FORMULATEXT(INDIRECT(RC8&""$I$13"",TRUE))"

In place of the 13. I know that the function is returning what I'm looking
for, but I just can't get it to work in the above formula. Can someone
assist?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Please help me find the problem with this

Barb,

IF cell H8 has a sheetname in it, then something like this would work:

Function MyRow(pattern As String) As Long
Dim myR As Range

Set myR = oWS.Range("C1:C15").Find(what:=pattern)
MyRow = myR.Row
End Function

Sub test()
ActiveCell.FormulaR1C1 = _
"=INDIRECT(RC8&""!$I$" & MyRow("Test") & """)"
End Sub

HTH,
Bernie
MS Excel MVP


"Barb Reinhardt" wrote in message
...
I have the following function:

Function MyRow(pattern As String)

oWB.Activate
oWS.Activate
Debug.Print "In MyRow function"
For i = 1 To 15
'Debug.Print i, Cells(i, "B").text, pattern
If Cells(i, "C").text Like pattern & "*" Then
MyRow = i
aWB.Activate
aWS.Activate
Debug.Print "MyRow = ", MyRow, Cells(i, "B").text, pattern
Exit Function
End If
Next i

End Function

I want to use it in the following formula

ActiveCell.FormulaR1C1 = _
"=FORMULATEXT(INDIRECT(RC8&""$I$13"",TRUE))"

In place of the 13. I know that the function is returning what I'm looking
for, but I just can't get it to work in the above formula. Can someone
assist?




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
Problem with 'Find' Dave Excel Discussion (Misc queries) 5 December 15th 09 01:27 PM
Find Next problem Terry K Excel Programming 8 November 21st 05 05:17 PM
problem with FIND cjsmith22 Excel Worksheet Functions 3 November 17th 05 11:03 PM
Find problem alanthecat Excel Programming 7 July 5th 05 01:17 PM
find problem John Excel Programming 4 July 3rd 04 08:30 AM


All times are GMT +1. The time now is 09:49 PM.

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"