Thanks Thanks:  0
Likes Likes:  0
Results 1 to 6 of 6

Thread: Need advice on coding for a logic statement in a macro

  1. #1
    Board Regular
    Join Date
    Mar 2010
    Location
    New England
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Need advice on coding for a logic statement in a macro

    1 other thing I am playing with, I am trying to choose the row with the latest data for a userform that displays the information.
    The ID for the item may be duplicated from a different day, so I need to make the selection only pull the current data defined by a date in row A.


    any ideas?

  2. #2
    Board Regular
    Join Date
    Mar 2010
    Location
    New England
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need advice on coding for a logic statement in a macro

    Another thing, this is in a logic statement before the userform adds the data to the form.

    I cannot get the verbiage right.

    DThib

  3. #3
    Board Regular
    Join Date
    Jul 2012
    Location
    Hampshire, UK
    Posts
    4,744
    Post Thanks / Like
    Mentioned
    19 Post(s)
    Tagged
    1 Thread(s)

    Default Re: Need advice on coding for a logic statement in a macro

    Quote Originally Posted by DThib View Post
    1 other thing I am playing with, I am trying to choose the row with the latest data for a userform that displays the information.
    The ID for the item may be duplicated from a different day, so I need to make the selection only pull the current data defined by a date in row A.


    any ideas?
    Hi,
    to find the row containing latest date in column A you could try incorporation following in your code & see if helps you

    Code:
    With Worksheets("Sheet1")
    
    
    MsgBox Application.Match(Application.Max(.Columns(1)), .Columns(1), 0)
    
    
    End With
    change sheet name as required

    Dave
    Last edited by dmt32; Apr 23rd, 2019 at 11:18 AM.

  4. #4
    Board Regular
    Join Date
    Mar 2010
    Location
    New England
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need advice on coding for a logic statement in a macro

    Thanks. I used the DATE function and it is comparing now, but the rest of my code to fill in the information on the userform with that line of data for the current date is blank.
    I think I am missing a command.
    Here is the code:

    Code:
    Dim WoWg As Worksheet
      Dim WGo As String
      Dim WGoW As Range
       On Error GoTo Rats
    
    
    
    
         SPR_W = Work_FRM.SPR_IDTB.Value
         Set WoWg = Sheets("Workable")
    
    
         Set WGoW = WoWg.Columns("B").Find(SPR_W, LookIn:=xlValues, LookAt:=xlWhole)
        If SPR_W <> "" And WoWg.Cells(WGoW.Row, 1).Value = Date Then
            WoWg.Activate
    
    
            WorkingRow = WorksheetFunction.CountA(Range("A:A"))
             Wprod_TB.Value = WoWg.Cells(WGoW.Row, 6).Value
             Wdaysw_TB.Value = WoWg.Cells(WGoW.Row, 12).Value
             WSum_TB.Value = WoWg.Cells(WGoW.Row, 7).Value
             Wsever_TB.Value = WoWg.Cells(WGoW.Row, 8).Value
             Wassign_TB.Value = WoWg.Cells(WGoW.Row, 3).Value
             Wserialn_TB.Value = WoWg.Cells(WGoW.Row, 9).Value
             Wdayso_TB.Value = WoWg.Cells(WGoW.Row, 13).Value
    
    
        Else
           MsgBox "Add Number", vbCritical + vbOKOnly, "Here we go..."
        End If
        Call Wister
    Rats:
     MsgBox "Information Missing", vbExclamation + vbOKOnly, "Error with SPR ID Information"
    
    
    End Sub
    Before adding the And for the date, it would fill out the data on the userform.
    Last edited by DThib; Apr 23rd, 2019 at 11:26 AM.

  5. #5
    Board Regular
    Join Date
    Mar 2010
    Location
    New England
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need advice on coding for a logic statement in a macro

    I keep trying to add the information from the current date's row and get nothing and then the comment box info gets placed in the wrong date row and overwrites current data.

    I need help fast, please.

  6. #6
    Board Regular
    Join Date
    Mar 2010
    Location
    New England
    Posts
    302
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Need advice on coding for a logic statement in a macro

    Figured out the hiccup.

    Works now

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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