Thread: Use a variabel
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Use a variabel

Alvin,

Be that as it may, it won't work in a worksheet function.

As I suggested, best to save it to a worksheet/ So where you have omroeder =
omroeder.value , use
Worksheets("Sheet1").Range("IV1").Value = onroeder.value

and in your worksheet use

INDIRECT.EXT("'c:\city breaks\priser\usa\"& Sheet1!$IV$1
&"\["&beregn!$B$1&".xls]prisliste'!$b$1"))



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
Wll
in my form i have
omroeder = omroeder.value ( omroeder.value is from a combobox)

My variabel omroeder i use in a module with
GetData "c:\city breaks\priser\usa\" & omroeder & "\byer.xls", "byer",
"A1:C200", Sheets("byer").Range("A1"), True

and here my variabel "omroeder" works

Alvin

"Bob Phillips" skrev:

If you mean that
INDIRECT.EXT("'c:\city breaks\priser\usa\"& omroeder
&"\["&beregn!$B$1&".xls]prisliste'!$b$1"))
is a worksheet function, you are way off track here. You cannot access a

VBA
variable directly from a worksheetfunction , you would need to use a UDF

and
call that to get the value, but of course, your true will have ended by

then
so the variable is likely to be empty unless you declare it static.

Your best way will be to use a worksheet cell and save the value in

there
and add that in the worksheetfunction (or use a workbook name).

BTW, how does omroeder = omroeder.Value work, it is not making sense to

me?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in message
...
Ok i try to explain

In my form i have
omroeder = omroeder.Value
in a module i have
Public omroeder

In a shette i have:
INDIRECT.EXT("'c:\city breaks\priser\usa\"& omroeder
&"\["&beregn!$B$1&".xls]prisliste'!$b$1"))

and here i get an error it can't find this file

Alvin


"Bob Phillips" skrev:

If you have declared it as public variable in a module, it should be
accessible anywhere, including a sheet.

What does not working mean exactly, an error or a wrong value? Where

did
you
store the variable?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alvin Hansen" wrote in

message
...
Hi
Thanks its working now
but i also use this variabel in a sheet
here it dosn't work ?

Alvin


" skrev:

Either pass it to the function in the module:

ModuleFunc(variable1)


or dont "dim" this in your form but rather dim it as
public in a module - and you can then access this variable
anywhere. However "global" variables of this type are
generally considered bad form and can lead to messy code
that is hard to debug. Generally you want to scope your
variables as tightly as possible.


-----Original Message-----
Hi!!

A variabel named in a form (general)
how and can I use this variabel in a macro (module)

Best regards alvin

.