hello I'm making a line graph with data on sheet 1. The problem is that I need only the data of today (20-03-2011) But I don't know how to select these cells of sheet1. This is the code I have.
code
Dim lrow, cRow, vandaag, vandaag2 As String
Dim j, x, y, z, tot As Integer
Dim myChartObject As ChartObject
Dim myChart As Chart
vandaag = CStr(Now)
vandaag = Mid(vandaag, 1, 11)
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection.NewSeries
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection.NewSeries
lrow = sheets("blad1").Range("B3:B4").End(xlDown).row
ActiveChart.SeriesCollection(1).Name = Date
For j = 1 To lrow
vandaag2 = Cells(2 + j, "B")
vandaag2 = Mid(vandaag2, 1, 11)
If vandaag2 = Date Then x = x + 1
Next
If lrow > 4221 Then
If x > 4221 Then
z = x + 1
Else
z = x
End If
Else
z = x + 1
End If
For y = 1 To z
ActiveChart.SeriesCollection(1).Values = "=blad1!$A$3:$A$" & y
ActiveChart.SeriesCollection(1).XValues = "blad1!$B$3:$B$" & y
ActiveChart.Axes(xlCategory).CategoryType = xlCategoryScale
ActiveChart.AutoScaling = True
Next y
Selection.Top = 50
Selection.Width = 400
Selection.Height = 350
Selection.Left = 30
End Sub
code
Dim lrow, cRow, vandaag, vandaag2 As String
Dim j, x, y, z, tot As Integer
Dim myChartObject As ChartObject
Dim myChart As Chart
vandaag = CStr(Now)
vandaag = Mid(vandaag, 1, 11)
ActiveSheet.Shapes.AddChart.Select
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection.NewSeries
ActiveChart.ChartType = xlLine
ActiveChart.SeriesCollection.NewSeries
lrow = sheets("blad1").Range("B3:B4").End(xlDown).row
ActiveChart.SeriesCollection(1).Name = Date
For j = 1 To lrow
vandaag2 = Cells(2 + j, "B")
vandaag2 = Mid(vandaag2, 1, 11)
If vandaag2 = Date Then x = x + 1
Next
If lrow > 4221 Then
If x > 4221 Then
z = x + 1
Else
z = x
End If
Else
z = x + 1
End If
For y = 1 To z
ActiveChart.SeriesCollection(1).Values = "=blad1!$A$3:$A$" & y
ActiveChart.SeriesCollection(1).XValues = "blad1!$B$3:$B$" & y
ActiveChart.Axes(xlCategory).CategoryType = xlCategoryScale
ActiveChart.AutoScaling = True
Next y
Selection.Top = 50
Selection.Width = 400
Selection.Height = 350
Selection.Left = 30
End Sub