+ Reply to Thread
Results 1 to 2 of 2

macro doubt

  1. #1
    Forum Contributor
    Join Date
    05-27-2004
    Posts
    119

    macro doubt

    Hi,
    I am in a preparation of report from my worksheet, what i wanted to know is how to get a selection of date wise report by using vba . For example if i wanted to make particular date ie. 25/1/2005. Anybody can give some idea about the code. My work sheet contains
    DATE\BILLNO\CUSTOMERNO\NAME\LCNO\TELNO\FCY\QNTY\RATE\LCY
    Any help or suggestions will be highly appreciated.
    with regards
    nowfal

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    You have a question, not a doubt.

    Assume that the row with the headers DATE\BILLNO\CUSTOMERNO\NAME\LCNO\TELNO\FCY\QNTY\RA TE\LCY is row 1.

    Sub testDate()
    Dim myRange As Range, myDate As Date

    enterDate:
    txtDate = InputBox("Please enter date")

    If IsDate(txtDate) Then
    myDate = DateValue(txtDate)
    Else:
    MsgBox txtDate & " is not a valid date"
    GoTo enterDate
    End If

    Set myRange = Range("A1").CurrentRegion
    numCells = myRange.Cells.Count
    lastRow = myRange.Cells(numCells).Row
    For i = lastRow To 2 Step -1
    If Not DateValue(Range("A" & i)) = myDate Then
    Rows(i).Delete Shift:=xlUp
    End If
    Next i
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1