0
votes

I'm having issues with piece of code. We use the following to search a log for a specific information, populate a chart and then print and clear the chart once completed.

The thing is, if we change the search criteria from CIS to Inbound (or anything else for that matter) it refuses to populate the chart with the information from the log, but still prints out the chart headers.

This is the code we're using:

Private Sub cmdprint_Click()

Dim sdsheet As Worksheet, ersheet As Worksheet
Set sdsheet = Workbooks("HD Project.xls").Sheets("HelpdeskLogg")
Set ersheet = Workbooks("HD Project.xls").Sheets("report")
dlr = sdsheet.Cells(Rows.Count, 1).End(xlUp).Row
rlr = ersheet.Cells(Rows.Count, 1).End(xlUp).Row

y = 2
For x = 2 To dlr

If UCase(sdsheet.Cells(x, 6)) = "Inbound" And CDate(sdsheet.Cells(x, 3)) >= CDate(Me.txtdatestart) And CDate(sdsheet.Cells(x, 3)) <= CDate(Me.txtdateend) Then





ersheet.Cells(y, 1) = CDate(sdsheet.Cells(x, 3))
ersheet.Cells(y, 2) = sdsheet.Cells(x, 6)
ersheet.Cells(y, 3) = sdsheet.Cells(x, 7)
ersheet.Cells(y, 4) = sdsheet.Cells(x, 8)
ersheet.Cells(y, 5) = sdsheet.Cells(x, 9)
ersheet.Cells(y, 6) = sdsheet.Cells(x, 10)
ersheet.Cells(y, 7) = sdsheet.Cells(x, 11)
ersheet.Cells(y, 8) = sdsheet.Cells(x, 12)
ersheet.Cells(y, 9) = sdsheet.Cells(x, 13)

y = y + 1
'On Error Resume Next

End If


Next x

Dim Lastrow As Integer
Lastrow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row


Set printa = ersheet.Range("A1:i" & Lastrow)


printa.PrintOut


Sheets("report").Range("a2:i999").ClearContents






End Sub
2
I feel this code is incomplete... you talk about charts but this code doesn't do that... - user2140173
My apologies I meant Table, not chart. My boss calls them charts. - A Passmore

2 Answers

1
votes

Try changing:

UCase(sdsheet.Cells(x, 6)) = "Inbound" to

UCase(sdsheet.Cells(x, 6)) = "INBOUND"
0
votes

Try changing:

UCase(sdsheet.Cells(x, 6)) = "Inbound" to

UCase(sdsheet.Cells(x, 6)) = "INBOUND"

This worked. Thank you for your help, barrleajo