'Get Cell Content in one sheet to another

I need to get my cell content in excel worksheet to another worksheet by using a user defined function. So I searched stackoverflow and found the following vba code.

Function GetValue(sheetName As String, cellAddress As String) As Variant
   GetSheetValue = ThisWorkbook.Sheets(sheetName).Range(cellAddress)
End Function

This is the right thing i expected.But it doesn't work for me. I need to develop a user defined function as like follows.

=GetContent(Sheet1,B6)

I've tried many things but I can't do it. So I'm very appriciate any responses about this matter. (Provide Screenshots about my example)

Thank You ScreenShot 02 ScreenShot 03



Solution 1:[1]

I've found the answer. My function must be correct as following code.

Function GetContent(sheetName As String, cellAddress As String) As String
    GetContent = ActiveWorkbook.Sheets(sheetName).Range(cellAddress)
End Function

I didn't concern abot the function name and return as the same. But we have to must do it. Also in string data type we have use quotaions and Case sensitive. So thanks all of you for valuable help. It helps me to fid out the answer. Now wecan use the functions as follows.

=GetContent("Sheet2","b5")

Thank You!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Roshan Aravinda