Need advice on coding for a logic statement in a macro

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
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?
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
Another thing, this is in a logic statement before the userform adds the data to the form.

I cannot get the verbiage right.

DThib
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
5,727
Office Version
2019
Platform
Windows
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:

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
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)
[COLOR=#b22222][U]    If SPR_W <> "" And WoWg.Cells(WGoW.Row, 1).Value = Date Then[/U][/COLOR]
        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:

DThib

Active Member
Joined
Mar 19, 2010
Messages
427
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,096,360
Messages
5,449,981
Members
405,580
Latest member
MRJT

This Week's Hot Topics

Top