Auto Function of Command Button

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
927
Office Version
2016
Platform
Windows
Hello To All,

I am using a command button with below code:

Private Sub CommandButton2_Click()
Sheet3.Range("d1") = Range("d1") + 1
End Sub

Now each time i press the button, 1 is added in cell d1 ....

Is there anyway that i can just press the button once and 1 starts adding in Cell D1 and does not stops unless and until i press it again.... or click it again i should say ......

PLS ITS URGENT

BEST REGARDS,

HUMAYUN
 

Some videos you may like

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
23,770
Something like this might work.

You could use a boolean flag and the OnTime method.
 
Last edited:

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
927
Office Version
2016
Platform
Windows
Dear Mikerickson

Thanks for your help .... but its not working

As i press the command button .... following msgbox appears which says

The macro "d:/visual basic.xls"!Incriment Cell' cannot be found

(my file name is visual basic saved in drive D:)

Pls help me out ...... its very urgent

I dont know how to deal with macro

HELP ME

AWAITING REPLY

HUMAYUN
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
927
Office Version
2016
Platform
Windows

ADVERTISEMENT

Dear Mikerickson,

I Do not know much about the modules - but i guess yes its a normal module ..........

Good to hear from you - now it seems like with your help - i will be able to overcome the problem

Awaiting Reply

Best Regards,

HUMAYUN
 

hrayani

Well-known Member
Joined
Jul 23, 2010
Messages
927
Office Version
2016
Platform
Windows
Dear Mikerickson,

I will explain it from the beginning.

I created a normal file in excel and named it Visual Basic

I am working on Sheet 1

I have the following values

A1=5
A2=5
A3=a1*a5=25

Now what i did is, i went to the the View option and then the toolbars
option and click on the control toolbox
Then i created a command button from the control toolbox on sheet 1

Then i entered the following code....

Private Sub CommandButton1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Sheet1.Range("a1") = Range("a1") + 1
End Sub

What i wanted was - when i press the command button 1 should be added in cell A1 and its happening .....

I havent done anything else .... this is regarding your question of modules - i mean to say that i havent applied anything else... i am saying this coz i dont know anything about the modules.... i guess you might have figured out that i am working on which module...

Now,,,, What i want is when i press the command button , then 1 should be added in cell A1 not stop unless and until i repress the command button again... in this way i will not have to press the command button again and again to add 1 in Cell A1....

Further more, do also let me know that is there anything like when i minimize the excel window to work on other windows then the adding 1 should not stop - unless and until i again maximize the excel window and repress the command button to stop adding 1 in Cell A1

I hope you would have understood.

Best Regards,

HUMAYUN
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,562
Messages
5,512,075
Members
408,878
Latest member
stams

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top