MS Excel Lookup and Reporting with Buttons and Macro Features

Please help with the following; I've made all corrections that I was able to research and figure out on my own.

Issues 7-11 - LOOKUP and Running the Report - Working WorkBook Attached!

Issue 7: Need VB Script to Conduct the LOOKUP and Place proper values in the cell range of the report.

Issue 8: Need the VB Script that runs the report to automatically enter the date and time in this cell once it has completed running.

Issue 9 : Need this in the VB Script as the first (of two) drivers for pulling records from Sheet1 to put into this report with the correct corresponding header/row data.

Issue 10: Need this in the VB Script as the second (of two) drivers for pulling records from Sheet1 to put into this report with the correct corresponding header/row data.

Issue 11: Need the correct corresponding information from Sheet 1 auto-populated during the running of the reports, based off of the Upcoming and Past Due date Lookups.
ckwillGWUAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dlmilleCommented:
These issues together may be a large scope than it should be for one E-E question which should take an expert up to 15-20 minutes to solve.  As a result, you may need to break these issues into pairs or something so they are more manageable.

For now, however, please upload your workbook so it can be assessed.

Cheers,

Dave
0
ckwillGWUAuthor Commented:
Thanks Dave,

Workbook Attached!
Test-Report-v2.xlsm
0
dlmilleCommented:
I see - this is scoped just right - its all about populating the report.  Thanks for posting the workbook.

Note, in the Desc sheet, VBA is not needed to post the last report run, as that data is already on the Report sheet, so a formula should suffice, correct?

Please review.

Here's the code (note, I changed your worksheet_change() code to deal with errors on the first if statement in the Sheet1 codepage - I did not dig into what that first features function is, but if there's an error, let it fall to the next).

Sheet1:
Dim PreviousValue

Private Sub Worksheet_Change(ByVal Target As Range)
    On Error Resume Next
    If Target.Value <> PreviousValue Then
        Sheets("log").Cells(65000, 1).End(xlUp).Offset(1, 0).Value = _
            Application.UserName & " changed cell " & Target.Address _
            & " from " & PreviousValue & " to " & Target.Value
    End If
    On Error GoTo 0
    If Target.Count > 1 Then Exit Sub 'not handling at the moment - this is if more than one cell is changed simultaneously
    If Not Intersect(Target, Range("F:F")) Is Nothing Then
        If Target.Value = "On Hold" And Left(Range("I" & Target.Row).Formula, 1) <> "=" Then 'prompt user
            MsgBox "Please Enter comments for On HOLD status"
        End If
    End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    PreviousValue = Target.Value
End Sub

Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
If Intersect(Target, [G1:G2090]) Is Nothing Then Exit Sub
 
Cancel = True
UserForm1.Show
End Sub

Open in new window


In a public module for the Report - and I assigned the button to this macro (button on the Desc sheet):
Option Explicit
Const DataToReportOrder = "3,1,2,4,5,6,7,9"
Sub populateReport()
Dim wkb As Workbook
Dim wksReport As Worksheet
Dim wksData As Worksheet
Dim rng As Range
Dim r As Range
Dim lastRow As Long
Dim outCursor As Range
Dim strOut As String
Dim vDataToReportOrder
Dim vOutput
Dim l As Long

    Set wkb = ThisWorkbook
    Set wksReport = wkb.Worksheets("Report")
    Set wksData = wkb.Worksheets("Sheet1")
    
    lastRow = wksReport.Cells.Find(what:="*", LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious).Offset(1, 0).Row
    
    'clear current report
    wksReport.Range("A5:J" & lastRow).ClearContents
    Set outCursor = wksReport.Range("A5")
    
    'read data and populate report
    lastRow = wksData.Cells.Find(what:="*", LookIn:=xlValues, lookat:=xlPart, searchorder:=xlByRows, searchdirection:=xlPrevious).Offset(1, 0).Row
    
    'get column lined up between data and report sheet
    vDataToReportOrder = Split(DataToReportOrder, ",")
    
    Set rng = wksData.Range("H2:H" & lastRow)
    
    For Each r In rng
        If r.Value <> vbNullString Then
            If r.Value <= DateValue(Format(DateValue(Now()), "MM/DD/YY")) + 8 Then  'look at next 7 days and also past due
                If r.Value >= DateValue(Format(DateValue(Now()), "MM/DD/YY")) Then 'due today/future
                    outCursor.Value = r.Value 'due date
                Else 'past due
                    outCursor.Offset(, 1).Value = r.Value 'due date
                End If
                
                'create output string delimited by || for each column of output
                
                strOut = wksData.Cells(r.Row, CLng(vDataToReportOrder(LBound(vDataToReportOrder)))).Value
                
                For l = LBound(vDataToReportOrder) + 1 To UBound(vDataToReportOrder)
                        strOut = strOut & "||" & wksData.Cells(r.Row, CLng(vDataToReportOrder(l))).Value
                Next l
                
                'output the result
                vOutput = Split(strOut, "||")
                outCursor.Offset(, 2).Resize(1, UBound(vOutput) + 1).Value = vOutput
                Set outCursor = outCursor.Offset(1, 0)
            End If
        End If
    Next r
    
    wksReport.Range("B2").Value = Now
    
    wksReport.Activate
    
End Sub

Open in new window


See attached.  I started from the last solution I did for you so you have less to deal with pulling it all together.

Enjoy!

Dave
Test-Report-v3.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ckwillGWUAuthor Commented:
Thanks again Dave!
0
ckwillGWUAuthor Commented:
Great work!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.