'---define objects----
Set objReadXL = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
'----define constance----
Const xlup = -4162
Const xlDown = -4121
Const xlToRight = -4161
Const xlToLeft = -4159
Const xlNone = -4142
Const xlCellTypeBlanks = 4
Sub ProcessingFullRunFile()
'Make excel spreadsheet visible
objReadXL.Visible = true
'Set variable definitions
Set objReadWB = objReadXL.Workbooks.Open(file2)
Set objReadWS = objReadWB.Sheets("Sheet1")
'Set objchart = objReadXL.Charts.Add()
With objReadWS
'Find the last non-blank cell in a single row or column
lastRow = .Range("B" & .Rows.Count).End(xlUp).Row
'Find the last non-blank cell in row 1
lastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
'select the range and loop each cell thats blank
'With .Range(.Cells(2, 2), .Cells(lastrow, lastCol))
With .Range("B2:C" & lastrow)
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=r[-1]c"
.Value = .Value
End With
End With
Set Source = objReadWS.Range("B4:D" & lastrow)
Set rng1 = objReadWS.Range("B4", objReadWS.Range("B4").End(xlDown))
Set rng2 = objReadWS.Range("C4", objReadWS.Range("C4").End(xlDown))
Set rng3 = objReadWS.Range("D4", objReadWS.Range("D4").End(xlDown))
Set rng4 = objReadWS.Range("J4", objReadWS.Range("J4").End(xlDown))
objReadXL.ActiveChart.HasTitle = True
objReadXL.ActiveChart.ChartTitle.Characters.Text = "Race"
objReadXL.ActiveChart.SetSourceData Source, 2
objReadXL.ActiveChart.Location 2, "Sheet1"
objReadXL.ActiveChart.ChartType = 63
objReadXL.ActiveChart.SeriesCollection(1).xValues = rng1
objReadXL.ActiveChart.SeriesCollection(1).Values = rng2
objReadXL.ActiveChart.SeriesCollection(2).xValues = rng1
objReadXL.ActiveChart.SeriesCollection(2).Values = rng3
objReadXL.ActiveChart.SeriesCollection(3).xValues = rng1
objReadXL.ActiveChart.SeriesCollection(3).Values = rng4
objReadXL.ActiveChart.Parent.Width = 1000
objReadXL.ActiveChart.Parent.Height = 500
objReadXL.ActiveChart.Parent.Left = 100
objReadXL.ActiveChart.Parent.Top = 100
Set objReadXL = Nothing
Set objReadWB = Nothing
End Sub