Question : How do I pass a cell reference through to my function code instead of the cell contents

I can usually figure out ways to do most things in excel and while the solutions may not be elegant they work.

This has me stumped

I am tring to program a function for using within the excel sheet. The function I have called latest  will in theory for the start cell chosen check to see if the cell in in the column with the right title (in my spread sheet ASP ) then check to see if the cell has a value or not. If it finds a value it returns it to the function and stops else moves progresivley to the right.

The Problem

I can't figur out how to carry the cell refrence though to the function whatever I try the starting cell shoesn when the user  inputs the arguments always returns the value of the start cell ans not it's Address I I want AN4 to come though ans I get the value in AN4 instead .

I appologize if this is very trivial but 4 hour later of internet searches and plying in the vb help and I am no further.

Also the soloution must allow the fomula to be copied down in the spread sheet and still return the correct numbers

Thanks in advance for suggestions

Regards to all

from

David

( an excel hack and amateur)
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
Function Latest(Columnheading As String, headingrow As Integer, startcell As Range)
 
Dim CH As String
Dim CHR As Integer
Dim DIR As Integer
Dim N As Integer
Dim X As Variant
 
CH = Columnheading
 
X = Range(startcell)
Range(X).Select
Range(X).Activate
N = Range(X).Row - headingrow
I = Range(X).Column
c = 0
Do Until c = I
 
If ActiveCell.Offset(-N, -c).Value = CH Then
If ActiveCell.Offset(N, -c).Value <> 0 Then
Latest = ActiveCell.Offset(N, -c).Value
End
Else
End If
Else
c = c + 1
End If
Loop
 
End Function

Answer : How do I pass a cell reference through to my function code instead of the cell contents

Try this:

Public Function ShowReference(S As Range)

    MsgBox S.Address

End Function
Random Solutions  
  •  How do you import outlook express 6 messages into Windows Live Mail and have them in the proper folders?
  •  Cannot use remote executables after I upgraded to R2
  •  How do I migrate Exchange 2003 Public Folder to Exchange 2007 using PFMigrate?
  •  VPN client (Check point Secure client) not able to browse to any website on the machine once connected to the VPN.
  •  How do I remove special characters in a query?
  •  Reading XML in to an ADO Recordset
  •  msaccess 2003 and turning on a new menu toolbar from module code and turning off the main menu from the same place
  •  DNS root hints not working Windows 2008
  •  can i use right([ClientName] to get the last part of a string in a Microsoft Access query if i don't know how long the last part is?
  •  How can I print using a Clipper (DOS) application under Windows 7
  •  
    programming4us programming4us