ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   macro with dynamic input (https://www.excelbanter.com/excel-worksheet-functions/140040-macro-dynamic-input.html)

Ahmaq

macro with dynamic input
 
Hi all

I want to pass on cell value of A1 into VB script every time i run a macro

which command should i use?


--
No one can steal your knowledge

Susan

macro with dynamic input
 
are you taking about VB or VBA? there's a difference.
if you're talking about VBA, then all you have to do is declare the
variable. as long as that worksheet is still open, the variable will
still be there.........

for code in THAT worksheet:

dim myValue as variant
myValue = worksheet("sheet1").range("A1")

for code in a DIFFERENT workbook (that must be open):
dim myValue as variant
dim wb1 as workbook
dim ws1 as worksheet

set wb1 = DifferentWorkbook.xls
set ws1 = Worksheets(1)

myValue = wb1.ws1.range("A1")

if you're talking about VB, i don't know. try the programming
newsgroup.
:)
susan




On Apr 23, 9:28 am, Ahmaq wrote:
Hi all

I want to pass on cell value of A1 into VB script every time i run a macro

which command should i use?

--
No one can steal your knowledge




Ahmaq

macro with dynamic input
 
Thanks Susan

I got hint from your reply

dim myValue as variant
myValue = worksheet("sheet1").range("A1")





--
No one can steal your knowledge


"Susan" wrote:

are you taking about VB or VBA? there's a difference.
if you're talking about VBA, then all you have to do is declare the
variable. as long as that worksheet is still open, the variable will
still be there.........

for code in THAT worksheet:

dim myValue as variant
myValue = worksheet("sheet1").range("A1")

for code in a DIFFERENT workbook (that must be open):
dim myValue as variant
dim wb1 as workbook
dim ws1 as worksheet

set wb1 = DifferentWorkbook.xls
set ws1 = Worksheets(1)

myValue = wb1.ws1.range("A1")

if you're talking about VB, i don't know. try the programming
newsgroup.
:)
susan




On Apr 23, 9:28 am, Ahmaq wrote:
Hi all

I want to pass on cell value of A1 into VB script every time i run a macro

which command should i use?

--
No one can steal your knowledge






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

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