Solved

Date Generator For it to show Days Left for due date

Posted on 2016-09-24
5
75 Views
Last Modified: 2016-09-24
Hello Experts Exchange Community, trying to create a code to do the following.

Search:
search for today date.

Then calculate how many days is left for each rows, that has dates on the "B" column.

Have it display on "G" column

Thanks guys for the help and your time.

Date-Generator.png
0
Comment
Question by:Omar Hernandez
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 31

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 500 total points
ID: 41813471
Assuming your date is in B6, then try this...

In G6
=IF(B6<>"",B6-TODAY(),"")

Open in new window

and then format the formula cell as General.
0
 

Author Comment

by:Omar Hernandez
ID: 41813489
Hey there Neeraj this code works great, anyway i can add it to this macro so that anytime i add this function this code will also be added on the I Collumn. I tried the following, but i had no luck.

Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("GENERAL")

If ActiveCell.EntireRow.Cells(1, 5) <> "" Then Label3.Caption = ActiveCell.EntireRow.Cells(1, 5)
    If ActiveCell.EntireRow.Cells(1, 4) <> "" Then Label4.Caption = ActiveCell.EntireRow.Cells(1, 4)
     If ActiveCell.EntireRow.Cells(1, 6) <> "" Then Label5.Caption = ActiveCell.EntireRow.Cells(1, 6)

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row

'check for a Name number
If Trim(Me.textbox_name.Value) = "" Then
Me.textbox_name.SetFocus
MsgBox "Please complete the form"
Exit Sub
End If

'copy the data to the database
        ws.Cells(iRow, 3).Value = "          " & Me.textbox_name.Value
        ws.Cells(iRow, 4).Value = Me.Label4.Caption
        ws.Cells(iRow, 5).Value = Me.Label3.Caption
        ws.Cells(iRow, 6).Value = Me.Label5.Caption
        ws.Cells(iRow, 7).Value = "2"
        ws.cells(irow, 9).value = IF(B7<>"",B7-TODAY(),"")


'clear the data
Me.textbox_name.Value = ""
Me.textbox_name.SetFocus
End Sub
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41813613
Maybe like this...
ws.Cells(iRow, 9).Formula = "=IF(B" & iRow & "<>"""",B" & iRow & "-TODAY(),"""")"
ws.Cells(iRow, 9).NumberFormat = "General"

Open in new window

0
 

Author Closing Comment

by:Omar Hernandez
ID: 41813616
Better than what i have expected thanks a mil Neeraj
0
 
LVL 31

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41813621
You're welcome Omar! Glad to help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question