Trying to add date & time using button / Numbers

  • Thread starter Thread starter Legacy 185509
  • Start date Start date
L

Legacy 185509

Guest
I am trying to add number to cell using button so don't have to use keyboard
the format of cell is
7/12/2011 15:00:00
First way
I can add date & month using +30 & +1 , I cannot time

Second way(data & time to decimal & fractions)
I can (-) subtract day by using -1
Type The Date And Time 12/12/2004 18:00 In Any Cell
Right Click In The Cell And Select Format Cells And Click The Number Tab, Then General Under Categories:
Look In The Sample: Box And You Should See 38333. 75, Where 38333 Represent The Date (Serial Number) And . 75 Represents The Time (Decimal Fraction).


second way look way better please help me to able to change date & time using vba & button
here is my code

to subtract 1
PHP:
Sub minzz()
Sheets("Sheet1").Select
Range("C1") = Range("C1") - 1
End Sub

to add 1
PHP:
Sub pluz()
Sheets("Sheet1").Select
Range("C1") = Range("C1") - 1
End Sub

+30 & -30
PHP:
Sub mminz()
Sheets("Sheet1").Select
Range("C1") = Range("C12") - 30
End Sub

Sub mpluz()
Sheets("Sheet1").Select
Range("C1").Value = Range("C1").Value + 30
'Range("C1") = Range("C1") + 30
End Sub
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
You don't say what time(s) you want to add/subtract.

For any time you will need to divide it appropriately:

A day in Excel is 1 so an hour is 1/24 and a minute is 1/24/60 and so on.
 
Upvote 0
I wanna make separate button 1 to add 1 hour other to subtract 1 hour
other to add 1 day & subtract 1 day & so on
 
Upvote 0

Forum statistics

Threads
1,224,567
Messages
6,179,571
Members
452,927
Latest member
whitfieldcraig

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