Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / January 2008

Tip: Looking for answers? Try searching our database.

Paste MsgBox Info to Cell??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TAlbertini - 10 Jan 2008 21:03 GMT
I have a MsgBox in which the user enters a start and end date to
create a report from data.  Is there a way to copy the information the
user enters in the MsgBox to cells on the worksheet so it is displayed
what dates are on the report.  I have put the code below, and I want
to put the start date in cell D:3 and the end date in cell D:4.  I
appreciate any help anyone could offer on this...

Private Sub CommandButton1_Click()
Dim dDate1 As Date, dDate2 As Date
   Dim lngdate1 As Long, lngdate2 As Long

   dDate1 = Application.InputBox(Prompt:="Enter a Start Date", _
   Title:="START DATE  FIND", Default:=Format(Date, "dd-mmm-yy"),
Type:=1)

    'Cancelled
   If dDate1 = 0 Then Exit Sub

   If Not IsDate(dDate1) Then
        MsgBox "Invalid Start Date", vbCritical
       Run "FindDateRange"
   End If

GetEndDate:
   dDate2 = Application.InputBox(Prompt:="Enter an End Date", _
   Title:="END DATE FIND", Default:=Format(Date, "dd-mmm-yy"),
Type:=1)

    'Cancelled
   If dDate2 = 0 Then Exit Sub

   If Not IsDate(dDate2) Then
       MsgBox "Invalid End Date", vbCritical
       GoTo GetEndDate
   End If

   lngdate1 = DateSerial(Year(dDate1), Month(dDate1), Day(dDate1))
   lngdate2 = DateSerial(Year(dDate2), Month(dDate2), Day(dDate2))

   ActiveSheet.AutoFilterMode = False
    Range("A7:A400").AutoFilter
   Range("A7:A400").AutoFilter Field:=1, Criteria1:=">=" & lngdate1,
_
   Operator:=xlAnd, Criteria2:="<=" & lngdate2
End Sub
Dave Peterson - 10 Jan 2008 21:10 GMT
Maybe something like:

with activesheet("d3")
  .numberformat = "mm/dd/yyyy"
  .value = date1
end with

> I have a MsgBox in which the user enters a start and end date to
> create a report from data.  Is there a way to copy the information the
[quoted text clipped - 41 lines]
>     Operator:=xlAnd, Criteria2:="<=" & lngdate2
> End Sub

Signature

Dave Peterson

CLR - 11 Jan 2008 13:38 GMT
Private Sub CommandButton1_Click()
Dim dDate1 As Date, dDate2 As Date
   Dim lngdate1 As Long, lngdate2 As Long

   dDate1 = Application.InputBox(Prompt:="Enter a Start Date", _
   Title:="START DATE  FIND", Default:=Format(Date, "dd-mmm-yy"), Type:=1)

Range("D1").Value = dDate1

    'Cancelled
   If dDate1 = 0 Then Exit Sub

   If Not IsDate(dDate1) Then
        MsgBox "Invalid Start Date", vbCritical
       Run "FindDateRange"
   End If

GetEndDate:
   dDate2 = Application.InputBox(Prompt:="Enter an End Date", _
   Title:="END DATE FIND", Default:=Format(Date, "dd-mmm-yy"), Type:=1)

Range("D2").Value = dDate1

    'Cancelled
   If dDate2 = 0 Then Exit Sub

   If Not IsDate(dDate2) Then
       MsgBox "Invalid End Date", vbCritical
       GoTo GetEndDate
   End If

   lngdate1 = DateSerial(Year(dDate1), Month(dDate1), Day(dDate1))
   lngdate2 = DateSerial(Year(dDate2), Month(dDate2), Day(dDate2))

   ActiveSheet.AutoFilterMode = False
    Range("A7:A400").AutoFilter
   Range("A7:A400").AutoFilter Field:=1, Criteria1:=">=" & lngdate1,
Operator:=xlAnd, Criteria2:="<=" & lngdate2
End Sub

> I have a MsgBox in which the user enters a start and end date to
> create a report from data.  Is there a way to copy the information the
[quoted text clipped - 41 lines]
>     Operator:=xlAnd, Criteria2:="<=" & lngdate2
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.