Indirect Variable Addressing

Copper Contributor

I've written vba code that includes the declared variable...

Dim  PB_Donors       As Integer

 

I'm now testing a Function that will return the following variables

GroupCountName As String

GroupCount As Integer

 

This function will typically returns the following...

 

GroupCountName = "PB_Donors"

GroupCount = 1

 

I need to transfer these returned results somehow into my declared variable PB_Donors.

 

Can anyone help? Thanks so much.

2 Replies

Have a few doubts.

The declared variable is an integer.

If you want to send the final value to PB DONORS, why don't you declare it at module level or public i.e. project level variable.

The output of first function is a string.What you want to do with that string. PB Donors is not going to take String as input as you have explicitly declared it.

gyankosh.net/vba 

@LaPaz5640 

Thanks for your input. I eventually found a way around this problem by creating named ranges in each of the pertinent Excel sheets. The ranges had the names CC_Donors, PB_Donors, etc and I was able to save the returned data for my function routine to the named ranges. The originally DIM declarations CC_Donors, PB_Donors, were no longer used. Maybe there is another way around this issue, but for now, it got me past my impasse! Thanks for participating.