Reference a variable declared in VBA

J

James

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!
 
S

sameoldcalvin

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
 
J

James

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
 
J

James

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top