ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Macro based on Cell Value (https://www.excelbanter.com/excel-worksheet-functions/191551-macro-based-cell-value.html)

NPell

Macro based on Cell Value
 
Hello, i have seen some macros but not exactly what i need.

I want the macro to run based on the value of a cell.
IE
A1 = "Y" .. Run Macro in D1
A2 = "Y" .. Run Macro in D2
.....
A7 = "Y" .. Run Macro in D7

Etc.

How can this be done?

Thanks

Rick Rothstein \(MVP - VB\)[_699_]

Macro based on Cell Value
 
Can you explain what "run Macro in D1" means? Do you mean you have several
different macros, one for each cell in Column D? Or do you have a single
macro that you want to run using the value contained in the cell in Column D
corresponding to the cell in Column A with the "Y" in it? If the first one,
what are the names of your macros. If the second one, posting your code
would probably be useful. Also, what is supposed to happen if more than one
cell in Column A has a "Y" in it? Finally, how far down Column A is your
"Etc." supposed to mean?

Rick


"NPell" wrote in message
...
Hello, i have seen some macros but not exactly what i need.

I want the macro to run based on the value of a cell.
IE
A1 = "Y" .. Run Macro in D1
A2 = "Y" .. Run Macro in D2
....
A7 = "Y" .. Run Macro in D7

Etc.

How can this be done?

Thanks



NPell

Macro based on Cell Value
 
On Jun 17, 4:42*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Can you explain what "run Macro in D1" means? Do you mean you have several
different macros, one for each cell in Column D? Or do you have a single
macro that you want to run using the value contained in the cell in Column D
corresponding to the cell in Column A with the "Y" in it? If the first one,
what are the names of your macros. If the second one, posting your code
would probably be useful. Also, what is supposed to happen if more than one
cell in Column A has a "Y" in it? Finally, how far down Column A is your
"Etc." supposed to mean?

Rick

"NPell" wrote in message

...



Hello, i have seen some macros but not exactly what i need.


I want the macro to run based on the value of a cell.
IE
A1 = "Y" .. Run Macro in D1
A2 = "Y" .. Run Macro in D2
....
A7 = "Y" .. Run Macro in D7


Etc.


How can this be done?


Thanks- Hide quoted text -


- Show quoted text -


Run Maco in D1 means i have a specific macro, which is;

Sub FillUsername()
ActiveCell.FormulaR1C1 = WindowsUserName
End Sub

And i want that to be populated in D1


If more than one cell in Column A has a Y in it, then it should be
irrelevant.
Basically if A1 has a Y... then the FillUsername macro populates in
D1.
Then if A3 = Y then FillUsername populates in D3

Etc. could go down as far as A2000.


All times are GMT +1. The time now is 11:50 AM.

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