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 .
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
x = R.Column
From within the sheet, and calling this function returns 0, although the function does calculate the correct value.
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.