Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-11-2011, 01:20 AM
Philip290 Philip290 is offline Creating a date box Windows 7 32bit Creating a date box Office 2010 32bit
Novice
Creating a date box
 
Join Date: May 2011
Posts: 3
Philip290 is on a distinguished road
Default Creating a date box


Hi, I'm trying to make a Excel sheet that will take data 'days' from one box, and add it to another..

for example:

Days on vacation: x
Date leave: October-20th-2011
Date return: above date + 'days on vacation' so if 7 was entered, it would return the date as October-27th-2011

Short/long form date doesn't matter. Also, how can I use the data on one sheet on another? I want a chart on the second sheet.

Thanks.

Last edited by Philip290; 05-11-2011 at 03:02 AM.
Reply With Quote
  #2  
Old 05-11-2011, 02:52 AM
macropod's Avatar
macropod macropod is offline Creating a date box Windows 7 32bit Creating a date box Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Philip,

Assuming your textboxes are on a userform and are named TextBox1, TextBox2 & TextBox3, with the date in TextBox1 and the # days in TextBox2, try:
Code:
Private Sub TextBox1_AfterUpdate()
If TextBox2.Value = "" Then TextBox2.Value = 0
MsgBox DateAdd("d", CInt(TextBox2.Value), CDate(TextBox1.Text))
TextBox3.Text = Format(DateAdd("d", CInt(TextBox2.Value), CDate(TextBox1.Text)), "DD/MMMM/YYYY")
End Sub
 
Private Sub TextBox2_AfterUpdate()
If TextBox1.Text = "" Then TextBox1.Text = Format(Now, "DD/MMMM/YYYY")
MsgBox DateAdd("d", CInt(TextBox2.Value), CDate(TextBox1.Text))
TextBox3.Text = Format(DateAdd("d", CInt(TextBox2.Value), CDate(TextBox1.Text)), "DD/MMMM/YYYY")
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-11-2011, 02:54 AM
Philip290 Philip290 is offline Creating a date box Windows 7 32bit Creating a date box Office 2010 32bit
Novice
Creating a date box
 
Join Date: May 2011
Posts: 3
Philip290 is on a distinguished road
Default

Hi macropod,

Thanks for the reply, I'm still a beginner to Excel, so I don't know what textboxes/userforms are; this is just a basic excel sheet using stuff like =Date(...).

Is there any way to do it in a simple fashion?
Reply With Quote
  #4  
Old 05-11-2011, 02:59 AM
OTPM OTPM is offline Creating a date box Windows 7 32bit Creating a date box Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

Hi Philip209
You can simply add the entry in one cell to the start date:
Example:
In a new column - A3+A2.
Where A3 is the start date of leave in date format and A2 is the number of days the member of staff is taking off.
Hope this helps.
Tony
Reply With Quote
  #5  
Old 05-11-2011, 03:01 AM
Philip290 Philip290 is offline Creating a date box Windows 7 32bit Creating a date box Office 2010 32bit
Novice
Creating a date box
 
Join Date: May 2011
Posts: 3
Philip290 is on a distinguished road
Default

Quote:
Originally Posted by OTPM View Post
Hi Philip209
You can simply add the entry in one cell to the start date:
Example:
In a new column - A3+A2.
Where A3 is the start date of leave in date format and A2 is the number of days the member of staff is taking off.
Hope this helps.
Tony

Hi OTPM, that's fantastic and exactly what I was after.

Thanks!
Reply With Quote
  #6  
Old 05-11-2011, 03:27 AM
macropod's Avatar
macropod macropod is offline Creating a date box Windows 7 32bit Creating a date box Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Philip,
Quote:
Originally Posted by Philip290 View Post
I'm still a beginner to Excel, so I don't know what textboxes/userforms are; this is just a basic excel sheet using stuff like =Date(...)
In that case, you need to learn the correct way of describing things. To refer to a textbox necessarily implies the use of a userform or an ActiveX control. If you want to work with cells on a worksheet, don't call them textboxes - call them cells. As you now know, adding a number to a date on a worksheet is very simple. Working with textboxes and userforms is not so simple and the solution is entirely different.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Date pop-up window Roshan Hanief Word 0 04-23-2011 04:16 AM
Creating an Auto-Calc'd Date? Today+7 Days? SoCalTelephone Word 0 10-06-2010 10:27 AM
Creating a date box Julian Date windseaker Excel 1 02-14-2010 01:44 AM
new appointment date always reverts back to today's date msills Outlook 0 08-24-2007 08:57 AM
Creating a date box Imported message date change to today's date promark Outlook 1 12-23-2005 07:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft