+ Reply to Thread
Results 1 to 22 of 22

Finding values entered in a column TODAY by the same user

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Finding values entered in a column TODAY by the same user

    • I have column A fully populated with values
    • I have a macro that when clicked, opens outlook express and sends an email to a vertical head with the latest entry # in column A.
    • No issues at all. Works fine. But I want to upgrade it
    • Is there a way to find out the values populated by a given user, in a particular day, in this case, today ?


    For eg:
    • If XYZ populated, Range A7,A8 and A9 yesterday.
    • Today, ABC populated Range 10,11 , 12 and 13:
    • Then the code today, should send an email to the vertical head saying , Range10,11,12 and 13 were updated today.

    My code uses the following :
    For finding last value in row :
    Range("A65536").End(xlUp).Value

    Code that sends the mail

    Set oout = CreateObject("Outlook.Application")
    Set omsg = oout.CreateItem(0)
    Dim ireply As String
    Dim LastRow As Range
    Dim SigString As String
    Dim Signature As String
    ireply = MsgBox(Prompt:="Is your OUTLOOK open ?", _
    Buttons:=vbYesNoCancel, Title:="UPDATE MACRO")
    
    If ireply = vbYes Then
    'LastRow = Cells(Rows.Count, "A").End(xlUp).row.Value
    
    With omsg
    .to = "edf@gmail.com"
    .CC = "elf@gmail.com "
    .BCC = ""
    .Subject = "Customer Service - Request ID # " & Range("A65536").End(xlUp).Value & "  added"
    .Body = "Dear edf," & vbNewLine & vbNewLine & " Customer Service Department just added  Request ID #  " & Range("A65536").End(xlUp).Value & "  to the list" & vbNewLine & "Due Date is :  " & Range("L65536").End(xlUp).Value & vbNewLine & vbNewLine & vbNewLine & "Thanks and Regards"
    .Display (True)
    
    End With
    ElseIf ireply = vbNo Then
    MsgBox ("Alright ! I will open that for ya ")
    Shell ("OUTLOOK")
    With omsg
    .to = "edf@gmail.com.com"
    .CC = "elf@gmail.com.com"
    .BCC = ""
    .Subject = "Customer Service - Request ID # " & Range("A65536").End(xlUp).Value & "  added"
    
    .Body = "Dear edf," & vbNewLine & vbNewLine & " Customer Service Department just added  Request ID #  " & Range("A65536").End(xlUp).Value & "  to the list" & vbNewLine & "Due Date is :  " & Range("L65536").End(xlUp).Value & vbNewLine & vbNewLine & vbNewLine & "Thanks and Regards"
    .Display (True)
    
    End With
    ElseIf ireply = vbCancel Then
    Exit Sub
    End If
                        '  If omsg.Sent Then   ' // HAVING ISSUES WITH THIS AS ON 10/30/2013...
                        '      MsgBox ("Sent")
                        '  Else
                        '     MsgBox (" Not Sent ! ")
                        '  End If
    Set oout = Nothing
    Set omsg = Nothing
                        'Exit Sub
                        '
    Last edited by subbby; 12-19-2013 at 03:50 PM. Reason: SOLVED

  2. #2
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    I am assuming that your data starts from row 2.

    use this code to get the range that was updated today.

    'code by xlbiznes
    Dim updated_range As String
    For x = 2 To Range("a" & Rows.Count).End(xlUp).Row
    
         If CDate(Range("A" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
         End If
    Next
    
    
    'to remove the last ,
    If update_range <> "" Then
    updated_range = Left(updated_range, Len(updated_range) - 1)
    End If
    
    MsgBox updated_range
    this code will go below this

    If ireply = vbYes Then
    'LastRow = Cells(Rows.Count, "A").End(xlUp).row.Value
    and this line

    .Subject = "Customer Service - Request ID # " & Range("A65536").End(xlUp).Value & "  added"
    will change to

    .Subject = "Customer Service - Request ID # " & updated_range & "  added"
    Happy Computing ,

    Xlbiznes.

    To show your appreciation please click *

  3. #3
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    It says VARIABLE NOT DEFINED, pointing at 'x'

    Would I have to add,

    Dim x as range
    Last edited by subbby; 12-19-2013 at 02:52 PM.

  4. #4
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    Its not needed,

    try adding this code.

    dim x as long

  5. #5
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Getting this error--. see attached pic3.jpeg

    Its highlighint "update_range" in

    If update_range <> "" Then
    Attached Images Attached Images

  6. #6
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    oops,it should be updated_Range not update_range. that was a typo

  7. #7
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    TYPE MISMATCH ERROR this time.. see attachment pic4.jpeg

    also, when i ran the code step by step using F8 it stopped at


      If CDate(Range("A" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
    Did highlight the first line in yellow : If CDate...
    Attached Images Attached Images

  8. #8
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Another pic for u attached.. pic5.jpeg
    Attached Images Attached Images

  9. #9
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    if you can post your updated code.

    I can simulate the issue.

  10. #10
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    at which line is this error occurring ?

  11. #11
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    see pic6.jpeg.

    one more hit of F8 TYPE MISMATCH ERROR 13 appears
    Attached Images Attached Images

  12. #12
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Here is the code

    Sub outlook2()
    Dim oout As Object
    Dim omsg As Object
    '  On Error GoTo ErrTrap '<============= add this line
    Set oout = CreateObject("Outlook.Application")
    Set omsg = oout.CreateItem(0)
    Dim ireply As String
    Dim LastRow As Range
    Dim SigString As String
    Dim Signature As String
    ireply = MsgBox(Prompt:="Is your Outlook open ?", _
    Buttons:=vbYesNoCancel, Title:="OUTLOOK")
    
    If ireply = vbYes Then
    'LastRow = Cells(Rows.Count, "A").End(xlUp).row.Value
    ' credits : xlbizness : date : 12/19/2013 : excel forum
    
    
    Dim x As Long
    Dim updated_range As String
    For x = 2 To Range("a" & Rows.Count).End(xlUp).row
    
         If CDate(Range("a" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
         End If
    Next
    
    
    'to remove the last ,
    If updated_range <> "" Then
    updated_range = Left(updated_range, Len(updated_range) - 1)
    End If
    
    MsgBox updated_range
    
    With omsg
    .To = "edf@gmail.com"
    .CC = "elf@gmail.com"
    .BCC = ""
    '.Subject = "Customer Service - Request ID # " & Range("A65536").End(xlUp).Value & "  added"
    .Subject = "Customer Service - Request ID # " & updated_range & "  added"
    .Body = "Dear Edf," & vbNewLine & vbNewLine & " Customer Service Department just added  Request ID #  " & Range("A65536").End(xlUp).Value & "  to the list" & vbNewLine & "Due Date is :  " & Range("L65536").End(xlUp).Value & vbNewLine & vbNewLine & vbNewLine & "Thanks and Regards"
    .Display (True)
    
    End With
    ElseIf ireply = vbNo Then
    MsgBox ("Alright ! I will open that for ya ")
    Shell ("OUTLOOK")
    With omsg
    .To = "edf@gmail.com"
    .CC = "elf@gmail.com"
    .BCC = ""
    .Subject = "Customer Service - Request ID # " & updated_range & "  added"
    '.Subject = "Customer Service - Request ID # " & Range("A65536").End(xlUp).Value & "  added"
    
    .Body = "Dear Edf," & vbNewLine & vbNewLine & " Customer Service Department just added  Request ID #  " & Range("A65536").End(xlUp).Value & "  to the list" & vbNewLine & "Due Date is :  " & Range("L65536").End(xlUp).Value & vbNewLine & vbNewLine & vbNewLine & "Thanks and Regards"
    .Display (True)
    
    End With
    ElseIf ireply = vbCancel Then
    Exit Sub
    End If
                        '  If omsg.Sent Then   ' // HAVING ISSUES WITH THIS AS ON 10/30/2013... GIVING A
                        '      MsgBox ("Sent")
                        '  Else
                        '     MsgBox (" Not Sent ! ")
                        '  End If
    Set oout = Nothing
    Set omsg = Nothing
                        'Exit Sub
                        'ErrTrap:
                        '
    End Sub

  13. #13
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    On which line did you get the error ?

    This code went through without any issues.

    I am assuming that column "A" is a date field, if not which column has the date values to be compared to current date ?

  14. #14
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Oopss.. My bad.. it was column B. Column A was full of request ID # (all integers)


    Having said that, just an addition to my initial query.

    In the subject it populates the dates... That is not wat should go there. The request ID is what has to go there...

    So how to choose the request IDs (from column A) that were filled today.

    Would it be

    updated_range.offset(0,-1) = updated_range & Range("B" & x) & ","
    Last edited by subbby; 12-19-2013 at 03:47 PM.

  15. #15
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    Ok,

    your date values are in column B and we need to extract the content in column a for rows that were updated today.

    So change this code :

    For x = 2 To Range("a" & Rows.Count).End(xlUp).row
    
         If CDate(Range("a" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
         End If
    Next
    to
    For x = 2 To Range("a" & Rows.Count).End(xlUp).row
    
         If CDate(Range("b" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
    
         End If
    Next

  16. #16
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Wonderful.... Thank you very much for your patience and helping me thru...

    REPS ADDED

  17. #17
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    You are welcome, glad that we got it solved.

  18. #18
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Can you please explain what this line in the code does?

    updated_range = updated_range & Range("a" & x) & ","
    I mean, I am looking for a way if I could declare and get corresponding values from column L as well ?
    Last edited by subbby; 12-19-2013 at 04:05 PM.

  19. #19
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    We are using a string variable named updated_range to store the values in the column A in the row X .

    Before this you have a if condition that checks that the date in row x of column "B" is equal to current date.
    So only on satisfying this condition the updated_Range string gets appended with the value in column "A".

    This happens till the last row is reached.

    At the end we have all your ID's in the string variable updated_range.

  20. #20
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Is there way to add another string ?
    I tried introducing due_date which shall be the corresponding values of the entires entered today.

    I just read the body of the email and it had due dates as well

    Now the story is :

    The customer servcie rep enters a Request ID (Column A) ; Date Initiated (Column B) and Due Date when the project is needed by (Column L)

    The body of the mail carries COLUMN L values as well

    so now that I get the request IDs, how can I get the Due dates as well.

    I tried to get in a string due_date. and tried the same way as "updated_range" ... but didnt work out

  21. #21
    Valued Forum Contributor xlbiznes's Avatar
    Join Date
    02-22-2013
    Location
    Bahrain
    MS-Off Ver
    Excel 2007
    Posts
    1,223

    Re: Finding values entered in a column TODAY by the same user

    Current you have this code for the Request ID to be collected
    For x = 2 To Range("a" & Rows.Count).End(xlUp).row
    
         If CDate(Range("b" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
    
         End If
    Next
    To also get the due date from the column L replace the above code with this.

    dim str_due_date as string
    
    For x = 2 To Range("a" & Rows.Count).End(xlUp).row
    
         If CDate(Range("b" & x).Text) = Date Then
         
         updated_range = updated_range & Range("a" & x) & ","
         str_due_date = str_due_Date &  range("L" & x).text & ","  'check if the date is extracted in the same format as it is in the sheet
         End If
    Next

  22. #22
    Forum Contributor
    Join Date
    08-24-2012
    Location
    Hollidaysburg, Pa
    MS-Off Ver
    Excel 2010
    Posts
    398

    Re: Finding values entered in a column TODAY by the same user

    Thanks a million tone.

    That answered all ! Worked well...


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Finding the nearest date in a column with reference to today
    By lenare in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-24-2013, 10:51 AM
  2. [SOLVED] How to filter specific values entered by user in array
    By shardin in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2013, 02:37 PM
  3. Open a excel userform with values previously entered by user using VBA
    By anuraag1 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-17-2013, 07:02 AM
  4. Link returned recordset with a user entered column
    By TheCyrusVirus in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2010, 07:10 AM
  5. Finding all dates in a column that are in the range today to a week from now
    By jrcream in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 10-01-2008, 09:32 PM

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