![]() |
Macro runs on cell value
Can I run the same macro or Subroutine from different Cells.
for example I want the Macro 'MyMacro()' to use the value in the cell. However I'm Not sure how to pass the string value in the cell to the macro If Cell A1 had 'Supplier' MyMacro would look like this =MyData(A1) I want to use the same Subroutine for other Cell value for example If Cell A2 has 'Customer' MyMacro would look like this =MyData(A2) -- Jeff |
Macro runs on cell value
Either this...
call MyMacro(Range("A2")) Public Sub MyMacro(ByVal Cell As Range) MsgBox Cell.Value End Sub or.... call MyMacro("A2") Public Sub MyMacro(ByVal Cell As String) MsgBox Range(cell).Value End Sub -- HTH... Jim Thomlinson "Jeff" wrote: Can I run the same macro or Subroutine from different Cells. for example I want the Macro 'MyMacro()' to use the value in the cell. However I'm Not sure how to pass the string value in the cell to the macro If Cell A1 had 'Supplier' MyMacro would look like this =MyData(A1) I want to use the same Subroutine for other Cell value for example If Cell A2 has 'Customer' MyMacro would look like this =MyData(A2) -- Jeff |
All times are GMT +1. The time now is 09:16 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com