cant seem to get a function to reference a variable cell?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top