View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default cant seem to get a function to reference a variable cell?

Sub ABC()
Dim rng as Range
Dim bRes as Boolean
ON error resume next
set rng = Application.InputBox("Select a column", type:=8)
On error goto 0
if rng is nothing then exit sub
set rng = rng(1).EntireColumn
bres = myFunc( rng)
End Sub

Public Function myFunc(myrng as Range) as Boolean
Dim r as Range
On Error goto ErrHandler
set r = Intersect(myrng,ActiveCell.entirecolumn)
r = r.offset(0,-1).value & r.value
myFunc = True
exit function
ErrHandler:
MyFunc = False
End Sub

--
Regards,
Tom Ogilvy




"Archie" wrote:

I want to ask a user to choose a column (eg input "E", for column E) and then
use this in a function in VB

eg to concatenate two cells A3 and E3, but I want the user to choose, say,
"E".

I can get the input but cant seem to get a function to reference a variable
cell?

Thanks