Question : Generate report  for invoice tracking

Hi Experts,

I would like to have Experts help to automate my report creation in sheet-2 based on information entered in "Invoice Tracker" (sheet-1). I have manually transferred first 2 information and I really need experts help to automate similar data extraction to sheet-2. Hope Expert can help me. I've attached the xls file for Experts perusal.

Answer : Generate report  for invoice tracking

Maybe like this?

Rob.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
Sub Generate_Report()
    Sheets(2).Range("A3:L1000").Clear
    For lngRow = 3 To Sheets(1).Cells(3, "A").End(xlDown).Row
        lngReportRow = Sheets(2).Cells(65536, "A").End(xlUp).Row + 1
        If lngReportRow = 2 Then lngReportRow = 3
        Sheets(2).Cells(lngReportRow, "A").Value = Sheets(1).Cells(lngRow, "B").Text
        lngTargetCol = FindTargetCol(Sheets(1).Cells(lngRow, "D").Value)
        If lngTargetCol > 0 Then
            Sheets(2).Cells(lngReportRow, lngTargetCol).Value = Sheets(1).Cells(lngRow, "G").Text
        Else
            MsgBox "Cannot find column for " & Sheets(1).Cells(lngRow, "D").Value & " from row " & lngRow
        End If
        Sheets(2).Cells(lngReportRow, "J").Value = Sheets(1).Cells(lngRow, "E").Text
        Sheets(2).Cells(lngReportRow, "K").Value = Sheets(1).Cells(lngRow, "F").Text
        Sheets(2).Cells(lngReportRow, "L").Value = Sheets(1).Cells(lngRow, "L").Text
    Next
End Sub
 
Private Function FindTargetCol(strColumnName)
    lngFoundCol = 0
    For lngCol = 2 To 9
        If LCase(Sheets("Report").Cells(2, lngCol).Value) = LCase(strColumnName) Then
            lngFoundCol = lngCol
            Exit For
        End If
    Next
    FindTargetCol = lngFoundCol
End Function
Random Solutions  
 
programming4us programming4us