Userform
Hello Patrick from Steved
Thankyou
I am getting a error which is
Compile error
Ambiguous Name detected:GetDistance,
Please understand I am relatively new in VBA programing
and still finding my way round. Ok saying that This is
what I believe your function is for me to type in cell A1
Riccarton and in Cell A2 Hornby in cell A3 Run the
Function Command which Shows Riccarton I then push ok it
is at this point it greats the error. Something tells me
that I have misred something here. Please help
-----Original Message-----
Sure, anything that you do in VBA can be done in a
userform....pretty much everything. But why use a
userform?
A simple User Defined Function will return the value
Function GetDistance(PlaceA As String, _
PlaceB As String) As Variant
Dim target As Range
Dim ResultRow As Long
Dim ResultCol As Long
' find the row of the first place
Set target = Range("A:A").Find(PlaceA)
If target Is Nothing Then
GetDistance = PlaceA & " not found."
Else
' save the row
ResultRow = target.Row
' find the second place
Set target = Range("1:1").Find(PlaceB)
If target Is Nothing Then
GetDistance = PlaceB & " not found."
Else
ResultCol = target.Column
End If
End If
If ResultRow 0 And ResultCol 0 Then
GetDistance = Cells(ResultRow, ResultCol)
End If
End Function
-----Original Message-----
Hello from Steved
Question can a userform be built so it can run a query
Example the query would be to find in Column A1
Riccarton
(Column A29), and in Row 1A Hornby (Row 1G). The result
would be that it would end up with the answer in G29 ie
15.6 Kilometres
Thanks in Advance
.
.
|