jump from cell content to command button

VBABEGINER

Well-known Member
Joined
Jun 15, 2011
Messages
1,284
Office Version
  1. 365
Platform
  1. Windows
Hi,

How to jump from cell content to command button?

i am entering value in cell b10. after click on tab button, can cursor go to command button? and then i put addition code of cells on click event of command button.
Pressing the enter button, command button gets clicked.

I dont know, whether this possible or not.

Any one know this? :eeek:
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
you cannot give a command button in a sheet the focus (unlike the buttons on a form), so you cannot activate the button with the Enter key.

What you could do is after the user has changed B10 show a form (or even a simple yes / no messagebox) which will run the same macro as is under the command button in the sheet.

Or if the macro needs to run anytime the user has made a change to B10, then rather than show a messagebox, run the macro immediately.

Right-click on the name tab of the sheet with B10, select 'View Code...'

The macro editor will open on the sheet module (code that is private to this sheet). Paste the following code into the editor. Then go to the sheet and make a change in cell B10.
Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim mbAnswer As VbMsgBoxResult
    If Not Intersect(Range("B10"), Target) Is Nothing Then
        mbAnswer = MsgBox("Do you want to run the macro?", vbYesNo, "Please select what to do")
        If mbAnswer = vbYes Then
            ' Run macro, enter name of macro here
            MsgBox "Run a macro instead of this stupid message box"
        End If
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,592
Messages
6,179,789
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top