Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Create VBA function (UDF) in Excel 2003
How do I code a function
CellVal(rownum, colnum [, sheetname]) that will be the equivalent of the worksheet formula: INDIRECT(ADDRESS(rownum, colnum [, sheetname])) that will return the value of the specified single cell? My knowledge of VBA is not good enough for me to find how to specify a single-cell RANGE by its co-ordinates. |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Create VBA function (UDF) in Excel 2003
Try the below. Sheetname is optional..
Function CellVal(lngRow As Long, lngColumn As Long, _ Optional strSheet As String) As Variant If strSheet = vbNullString Then strSheet = Application.Caller.Worksheet.Name CellVal = Sheets(strSheet).Cells(lngRow, lngColumn).Value End Function If this post helps click Yes --------------- Jacob Skaria "Hershmab" wrote: How do I code a function CellVal(rownum, colnum [, sheetname]) that will be the equivalent of the worksheet formula: INDIRECT(ADDRESS(rownum, colnum [, sheetname])) that will return the value of the specified single cell? My knowledge of VBA is not good enough for me to find how to specify a single-cell RANGE by its co-ordinates. |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
Create VBA function (UDF) in Excel 2003
Needs to be Volatile
Function CellVal(lngRow As Long, lngColumn As Long, _ Optional strSheet As String) As Variant Application.Volatile on Error GoTo Fail: If strSheet = vbNullString Then strSheet = Application.Caller.Parent.Name CellVal = Sheets(strSheet).Cells(lngRow, lngColumn).Value exit function Fail: CellVal=cverr(xlerrna) End Function Charles ___________________________________ The Excel Calculation Site http://www.decisionmodels.com "Jacob Skaria" wrote in message ... Try the below. Sheetname is optional.. Function CellVal(lngRow As Long, lngColumn As Long, _ Optional strSheet As String) As Variant If strSheet = vbNullString Then strSheet = Application.Caller.Worksheet.Name CellVal = Sheets(strSheet).Cells(lngRow, lngColumn).Value End Function If this post helps click Yes --------------- Jacob Skaria "Hershmab" wrote: How do I code a function CellVal(rownum, colnum [, sheetname]) that will be the equivalent of the worksheet formula: INDIRECT(ADDRESS(rownum, colnum [, sheetname])) that will return the value of the specified single cell? My knowledge of VBA is not good enough for me to find how to specify a single-cell RANGE by its co-ordinates. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i create a dashboard in excel 2003 ? | Excel Discussion (Misc queries) | |||
How do I create a dashboard using Excel 2003? | Charts and Charting in Excel | |||
How to create a template in Excel 2003 | Excel Discussion (Misc queries) | |||
Excel 2003, Insert Function, create full name & descriptions | Excel Worksheet Functions | |||
How do I create a geographic map in Excel 2003? | Excel Worksheet Functions |