ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro control (https://www.excelbanter.com/excel-programming/284365-macro-control.html)

Edwin Merced

Macro control
 
How do I instruct a macro to respond to a variable outside of the VB editor?



David

Macro control
 
Sort of vague. Where is the variable? In a cell on a
worksheet? Need to us a little more input here.
-----Original Message-----
How do I instruct a macro to respond to a variable

outside of the VB editor?


.


D.S.[_3_]

Macro control
 
I might suggest a couple ways, but not sure exactly what your trying to do.
Here's one example.

In the VB Editor "Project Explorer", right click on "ThisWorkbook", and
select "View Code". Click the drop down box on the left side, and pick
workbook. Now click the right drop down box and select
"SheetSelectionChange"

add the following code

If ActiveCell.Value = "test" Then
Range("B1").Value = "test"
Else
Range("B1").Value = ""
End If

Now, go to cell "A1" in your worksheet and type the word "test" (without the
quotes)

Now watch what happens in "B1" when you click the mouse on any cell except
"A1", then try clicking on "A1".

Is this anything like you're looking for? You can use other workbook events
to trigger your code. Look up "workbook object" in the VB Editor Help menu,
then select "Events"

Did this help?

D.S.


"Edwin Merced" wrote in message
...
How do I instruct a macro to respond to a variable outside of the VB

editor?





Edwin Merced

Macro control
 
But what I would like is to write in a cell and make that go to the code in
VBA. Is it possible?

"D.S." wrote in message
...
I might suggest a couple ways, but not sure exactly what your trying to

do.
Here's one example.

In the VB Editor "Project Explorer", right click on "ThisWorkbook", and
select "View Code". Click the drop down box on the left side, and pick
workbook. Now click the right drop down box and select
"SheetSelectionChange"

add the following code

If ActiveCell.Value = "test" Then
Range("B1").Value = "test"
Else
Range("B1").Value = ""
End If

Now, go to cell "A1" in your worksheet and type the word "test" (without

the
quotes)

Now watch what happens in "B1" when you click the mouse on any cell

except
"A1", then try clicking on "A1".

Is this anything like you're looking for? You can use other workbook

events
to trigger your code. Look up "workbook object" in the VB Editor Help

menu,
then select "Events"

Did this help?

D.S.


"Edwin Merced" wrote in message
...
How do I instruct a macro to respond to a variable outside of the VB

editor?







D.S.[_3_]

Macro control
 
Not that I know of.

D.S.
"Edwin Merced" wrote in message
...
But what I would like is to write in a cell and make that go to the code

in
VBA. Is it possible?

"D.S." wrote in message
...
I might suggest a couple ways, but not sure exactly what your trying to

do.
Here's one example.

In the VB Editor "Project Explorer", right click on "ThisWorkbook", and
select "View Code". Click the drop down box on the left side, and pick
workbook. Now click the right drop down box and select
"SheetSelectionChange"

add the following code

If ActiveCell.Value = "test" Then
Range("B1").Value = "test"
Else
Range("B1").Value = ""
End If

Now, go to cell "A1" in your worksheet and type the word "test" (without

the
quotes)

Now watch what happens in "B1" when you click the mouse on any cell

except
"A1", then try clicking on "A1".

Is this anything like you're looking for? You can use other workbook

events
to trigger your code. Look up "workbook object" in the VB Editor Help

menu,
then select "Events"

Did this help?

D.S.


"Edwin Merced" wrote in message
...
How do I instruct a macro to respond to a variable outside of the VB

editor?










All times are GMT +1. The time now is 12:03 PM.

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