ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Reference a variable declared in VBA (https://www.excelbanter.com/excel-worksheet-functions/202380-reference-variable-declared-vba.html)

James

Reference a variable declared in VBA
 
I have a question and dont have the slightest idea on how to go about it.
I have a cell G8 that will get text input to it. If G8 has text in it, then
cell B8 will input the persons name retrieved from VB with a public variable
name of "name."
I was thinking the best way to do this is with a formula in cell B8 that is
something like:

=IF(Range("G7").Value<"",Module1.Name,"")

Module1.Name is the Module and Public Variable in that module that i want to
reference.
any help would be great, not too familliar with formulas. thanks again!

sameoldcalvin

Reference a variable declared in VBA
 
I don't think you can get the variable from the VBA to the excel sheet
for formula use...

you either have to chnage the VBA, or you could do it in excel without
the VBA


one thing you could do is, to assign the names from the VBA to a list
on the worksheet(let's say it's P1) and then do Vlookup to match up
the name and values...


I'm not sure what's the situation is like, nor you're familiarity with
excel

James

Reference a variable declared in VBA
 
Ok, i think what im going to do is just output the value of the variable to
the sheet somewhere and then use that cell that i output to in the formula.
thanks for the response. much appreciated

"sameoldcalvin" wrote:

I don't think you can get the variable from the VBA to the excel sheet
for formula use...

you either have to chnage the VBA, or you could do it in excel without
the VBA


one thing you could do is, to assign the names from the VBA to a list
on the worksheet(let's say it's P1) and then do Vlookup to match up
the name and values...


I'm not sure what's the situation is like, nor you're familiarity with
excel


James

Reference a variable declared in VBA
 
ok, so if i output the variable contents to Range("I2") how do i implement the
range("G7").value<"" in the IF formula?

"sameoldcalvin" wrote:

I don't think you can get the variable from the VBA to the excel sheet
for formula use...

you either have to chnage the VBA, or you could do it in excel without
the VBA


one thing you could do is, to assign the names from the VBA to a list
on the worksheet(let's say it's P1) and then do Vlookup to match up
the name and values...


I'm not sure what's the situation is like, nor you're familiarity with
excel



All times are GMT +1. The time now is 11:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com