Thursday, March 28, 2013

I function from Excel cell to assign a macro can be?


Real question basically by John: In excel can I assign a macro to a cell with a function?

I’m wanting to click on a cell that contains a function based on other cells. Is there a way for me to click on that cell, and have it automatically populate another separate cell that it doesn’t run off of? For example, cell A1 is a vlookup function based on cells C1:D10. I want to be able to click on the cell A1 and have it auto-populate cell A2 with the word “VIRUS!”. Hope that makes sense.


It will be interesting facts about In excel can I assign a macro to a cell with a function? that you will choose to solve situations in their own business. I hope this will assist you in many ways, as well as yourself better. In hopes interesting facts about In excel can I assign a macro to a cell with a function? happens to be a method one day.

Best solution:


Answer by garbo7441

Use a Worksheet_SelectionChange event handler. Copy the following code to the clipboard (highlight the entire code, right click inside the highlighted area, and ‘Copy’):


Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Address(0, 0) = “A1″ Then

Range(“A2″).Value = “VIRUS!”

Else

Range(“A2″).Value = “”

End If

End Sub


Select the worksheet you wish to employ this in and right click the sheet tab at the bottom.


Select ‘View Code’.


Paste the event handler into the white editing area to the right (right click inside the area and ‘Paste’).


Close the VBE (red button w/white ‘x’ at the top right).


Select cell A1 and ‘VIRUS!’ will be returned in cell A2. Select any other cell and cell A2 will be cleared.


Acknowledge much better?

Add your individual answer into the comments!


a start goto a.



I function from Excel cell to assign a macro can be?

No comments:

Post a Comment

Blog Archive