PC Review


Reply
Thread Tools Rate Thread

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

 
 
=?Utf-8?B?QXJjaGll?=
Guest
Posts: n/a
 
      22nd Jun 2007
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
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      22nd Jun 2007
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

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
reference a function name by the value in a string variable Mike P Microsoft Access VBA Modules 3 8th May 2009 08:29 PM
Variable reference in a function Wildebraam Production Microsoft Excel Worksheet Functions 3 25th Apr 2009 03:50 PM
MIN Function w/ variable address reference =?Utf-8?B?V0xNUGlsb3Q=?= Microsoft Excel Worksheet Functions 7 10th Jun 2005 07:56 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. twister212atop@yahoo.com Microsoft Excel Worksheet Functions 2 11th Dec 2004 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable twister212atop@yahoo.com Microsoft Excel Worksheet Functions 2 11th Dec 2004 12:00 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 AM.