![]() On the worksheet with the cell you need to click to run a Macro, right click the sheet tab, and then click View Code from the context menu.Ģ. The following VBA code can help you to run a Macro by clicking a specific cell in Excel. ![]() Trigger or run a Macro by clicking a specific cell with VBA code But do you know how to run a Macro by just clicking on a specific cell in a worksheet? This article will show you method of triggering a Macro by clicking on a specific cell in details. While working with Microsoft Excel, you may know how to run a certain Macro with a Command Button. If Target.Column = 1 And Target.ActiveCell ThenĬall Back_to_JE 'A different macro I have which brings the user back to the main formĪctiveCell.Value = Range("F:F").Select ' I want the value the user clicked on in the gotoref# macors to populate the corresponding F column in original macroHow to trigger or run a Macro by clicking a specific cell in Excel? Private Sub Worksheet_SelectionChange(ByVal Target As Range) **'I have also Tried this approach after the Worksheet_SelectionChange() event:** If Target.Column = 1 And = 1 Then ' the Range the user will click in the gotoref# macros will be column AĬall Back_to_JE 'A different macro I created to navigate user back to main formĪctiveCell.Value = Range("F:F").Select ' I want the value the user clicked on in the gotoref# macros to populate the corresponding F column in original formĪctiveCellInterior.ColorIndex = 0 'I want the color of the F cell to go back to white bckgrnd when a value is present in the cell. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)'This sub will attempt to perform the double click in gotoref# macro's and populate the F column in the original form and change the color back to white background. If Target.Column = 6 And = 1 And = 3 Then Private Sub Worksheet_SelectionCHange(ByVal Target As Range) Private Sub Worksheet_Change(ByVal Target As Range) If you need more elaboration or explaining, I'd be happy to do so. Also, for some reason, I have to click inside the D column for the cell in the F column to turn red, rather than just automatically turning red. ![]() ![]() The issues I am having now is that I am able to navigate to the macros but, I can not double-click on a value in the A column inside the macros and it doesn't navigate back to the red colored F cell in the original form. All cells in column D are formatted like: '=MID(cell,16,6)' Note: The values being entered in column D are derived from a larger value in column C. Once the user is taken to the correct macro (after clicking cell F10),I would like the user to be able to double-click any value in the A column inside the macro and the value the user double-clicks to populate the red F10 cell and for the color of cell F10 to go back to white, now just displaying the value the user has selected rather than being blank and red. Once the F column turns red, the user is able to click on the red colored cell and it will navigate them to the macro associated with that value.Įxample: If cell D10 = "20PART", cell F10 will turn red ( to let the user know they need to click on the cell to complete the form) and when the user clicks on cell F10 it will take them to the macro gotoref6 (this is the macro assoc. I currently have a form that, based on a number of values, if one of those values is entered into the D column, the corresponding F column will turn red. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |