Function that returns a string

masterkemist

New Member
Joined
Feb 1, 2005
Messages
11
I have a relative sheet reference function that returns a string as in

refonprevsheetname("G10")

I understand that it is a string but I want the row number to change as I move down the column. This way I can drag the fill handle down instead of typing each one out. Can anyone offer any solutions?
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
masterkemist said:
I have a relative sheet reference function that returns a string as in

refonprevsheetname("G10")

I understand that it is a string but I want the row number to change as I move down the column. This way I can drag the fill handle down instead of typing each one out. Can anyone offer any solutions?

I maybe missing something here, but

=SheetName!G10

and drag down
 
Upvote 0
Yeah...

I want the next row down to read

refonprevsheetname("G11")

then

refonprevsheetname("G12")

then

refonprevsheetname("G13")

etc, etc, etc.

Does that make more sense or am I missing something. After all, I am a newbie :pray:
 
Upvote 0
You could do it by incorporating the ROW() function. For example, if your first formula is in row 5, you could use:

=refonprevsheetname("G"&ROW()+5)

Not a very elegant approach but it will work. Hope that helps!
 
Upvote 0
masterkemist said:
I have a relative sheet reference function that returns a string as in

refonprevsheetname("G10")

I understand that it is a string but I want the row number to change as I move down the column. This way I can drag the fill handle down instead of typing each one out. Can anyone offer any solutions?

That must be a UDF. Not sure it can handle a result from another function, but it should...


=refonprevsheetname(CELL("Address",G10))
 
Upvote 0
Tom

Do you really need to pass a string to the UDF?

Perhaps you could post the code for the UDF and an explanation of what it's supposed to do?
 
Upvote 0
Sure... I'd be happy to post the udf vba code

Code:
'this will return a cell from the previous sheet'
Function RefOnPrevSheetName(Addr As String) As Variant
    Application.Volatile True
    With Application.Caller.Parent
    If .Index = 1 Then
        RefOnPrevSheetName = _
        .Parent.Worksheets.Range(Addr).Value
    Else
        RefOnPrevSheetName = .Previous.Range(Addr).Value
    End If
    End With
End Function

If you have any more elegant solutions, I'm totally open. I am very much a newbie to vba. :LOL:
 
Upvote 0

Forum statistics

Threads
1,213,534
Messages
6,114,184
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top