Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 8th, 2006, 04:06 PM
Authorized User
 
Join Date: Nov 2006
Location: Adelaide, SA, Australia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default user function attempt

Am a novice with advanced VBA.

I am trying to establish the column number for a cell via a user defined function. My ultimate aim is to establish offset values of named cells in row 1 of particular sheet. These values make a columnar list on another sheet.

Public Function GetCol(R As Range) As Long

    Dim x
   x = R.Column

End Function

From within the sheet, and calling this function returns 0, although the function does calculate the correct value.

Anyone help me out here? - regards dennis


Reply With Quote
  #2 (permalink)  
Old November 8th, 2006, 04:16 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Hey Dennis,

VBA is sneaky with this. Rather than a return value, what you want to do is set GetCol to the value you want to return. Add a line with GetCol = x and you should be good to go. Or you could just remove x from the function entirely.

Mike

Mike
EchoVue.com
Reply With Quote
  #3 (permalink)  
Old November 8th, 2006, 05:36 PM
Authorized User
 
Join Date: Nov 2006
Location: Adelaide, SA, Australia.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Mike, works a treat. I was hoping the answer might be as simple as that.

regards dennis

Reply With Quote
  #4 (permalink)  
Old November 8th, 2006, 05:59 PM
Friend of Wrox
 
Join Date: Oct 2004
Location: Clinton, UT, USA.
Posts: 564
Thanks: 0
Thanked 4 Times in 4 Posts
Default

No Worries Dennis, Nice easy problems, but then you don't know whether to kick yourself, or just be relieved.

Welcome to the forum - you'll find it an invaluable resource as you get more into VBA.

Mike

Mike
EchoVue.com
Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Go for View or User Defined function vinod_yadav1919 SQL Server 2000 1 December 12th, 2007 05:18 AM
Search Function and User Controls hpox BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 3 January 8th, 2007 11:00 AM
Search Function and User Controls hpox ASP.NET 2.0 Professional 0 December 22nd, 2006 02:27 PM
Calling User Defined Function penta Access 5 March 4th, 2005 12:57 PM
User Defined Function niravp SQL Server 2000 7 November 29th, 2004 02:18 PM



All times are GMT -4. The time now is 11:46 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.