Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Excel Macro calling VB code ActiveCell.Formula issue with date

Posted on 2013-11-13
2
Medium Priority
?
345 Views
Last Modified: 2013-11-14
I have a hotkey setup to call a Macro that is VB code.

I get the input box and after entering a date the cells update with #name value instead of doing the date calculation.

I've tried this:

    Dim agedate As String
    agedate = InputBox("enter age from date mm/dd/yyyy", "Data Entry")
    result = CDate(agedate)
    Dim adate As Date
    adate = DateValue(agedate)
    ActiveCell.FormulaR1C1 = "=DAYS360([@[Disch Date]]," & adate & ")"


And this:

    Dim AgeDate As Date
    AgeDate = InputBox("Enter date of ATB mm/dd/yyyy", "Data Entry")
    ActiveCell.FormulaR1C1 = "=DAYS360([@[Disch Date]],AgeDate)"


Any help would be appreciated.

Regards,
Torrey
0
Comment
Question by:Torrey Bates
[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
2 Comments
 
LVL 81

Accepted Solution

by:
byundt earned 2000 total points
ID: 39647041
Torrey,
Assuming that you are using m/d/yyyy short date format, you can use:
    Dim agedate As String
    agedate = InputBox("enter age from date mm/dd/yyyy", "Data Entry")
    ActiveCell.FormulaR1C1 = "=DAYS360([@[Disch Date]],""" & agedate & """)"

Open in new window

Brad
0
 
LVL 2

Author Closing Comment

by:Torrey Bates
ID: 39648977
Thanks!
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

661 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