NotBillGates
New Member
- Joined
- Jul 1, 2016
- Messages
- 13
Hi
I am trying to update a cell A2 with a different value depending on which macro I run. Each macro is run from a text box placed over a different cell.
In each cell A1 to Z1 have a unique piece of text e.g. A1 = Reason1, B1 Reason 2 etc
I have a textbox over each cell which gets its text from the cell underneath e.g. text box over A1 has =A1, B1 =B1
I can attach a macro to each text box with the following
Textbox over A1
Sub Reason1
Range("A2").value = range ("A1").value
End Sub
Textbox over B1
Sub Reason2
Range("A2").value = range ("B1").value
End Sub
Textbox over Z1
Sub Reason2
Range("A2").value = range ("Z1").value
End Sub
Is there a way to use a single macro for all text boxes that links to the cell below the textbox. So when run from textbox over A1 Active cell is A1, when run from textbox over B1 Active cell is B1
Sub SingleMacro
Range("A2").Value = Activecell.Value
End Sub
Alternatively if I get rid of the text boxes how do I run a macro if cell A1, B1, C1...Z1 are selected, but not run if any other cell is selected.
Hope this makes sense
Thanks
I am trying to update a cell A2 with a different value depending on which macro I run. Each macro is run from a text box placed over a different cell.
In each cell A1 to Z1 have a unique piece of text e.g. A1 = Reason1, B1 Reason 2 etc
I have a textbox over each cell which gets its text from the cell underneath e.g. text box over A1 has =A1, B1 =B1
I can attach a macro to each text box with the following
Textbox over A1
Sub Reason1
Range("A2").value = range ("A1").value
End Sub
Textbox over B1
Sub Reason2
Range("A2").value = range ("B1").value
End Sub
Textbox over Z1
Sub Reason2
Range("A2").value = range ("Z1").value
End Sub
Is there a way to use a single macro for all text boxes that links to the cell below the textbox. So when run from textbox over A1 Active cell is A1, when run from textbox over B1 Active cell is B1
Sub SingleMacro
Range("A2").Value = Activecell.Value
End Sub
Alternatively if I get rid of the text boxes how do I run a macro if cell A1, B1, C1...Z1 are selected, but not run if any other cell is selected.
Hope this makes sense
Thanks