Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default cant seem to get a function to reference a variable cell?

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Variable reference in a function Wildebraam Production Excel Worksheet Functions 3 April 25th 09 03:50 PM
A function to get a variable row reference for range in XNPV funct Tex1960 Excel Worksheet Functions 6 August 1st 05 11:20 PM
MIN Function w/ variable address reference WLMPilot Excel Worksheet Functions 7 June 10th 05 07:56 PM
problem with cell reference in =sum(offset(cell reference,x,y,z,a)). Want cell ref to be variable. [email protected] Excel Worksheet Functions 2 December 11th 04 12:05 AM
Problem with =sum(offset(cell reference,w,x,y,z). I want cell reference to be variable [email protected] Excel Worksheet Functions 2 December 11th 04 12:00 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"