Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofill in Excel 1

Status
Not open for further replies.

EEalmost

Technical User
Jun 14, 2007
7
This should be easy, but I'm having a hard time getting the format correct.

I just want to select say cells(1,1) and do a default autofill from Range("A1:A10"), but I'm not sure how to write it in VBScript.
Thanks
 
Use the macro recorder in Excel and then adapt the generated VBA code to VBS automation code.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the quick response PHV,

I know about the macro recorder. I'm not sure how to adapt the following to VBScript, because I keep getting errors:

Range("A3").Select
ActiveCell.FormulaR1C1 = "I 0.0"
Range("A3").Select
Selection.AutoFill Destination:=Range("A3:A17"), Type:=xlFillDefault
 
Please, post the VBS code instantiating Excel and the Workbook.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Const xlEdgeTop = 8
Const xlEdgeRight = 10
Const xlContinuous = 1
Const xlThin = 2

Set objXL = CreateObject("Excel.Application")
objXL.Visible = Visible

Call NewSpreadsheet(x)
objXL.Quit

Function NewSpreadsheet(numPLC)
objXL.Workbooks.Add

objXL.Worksheets(1).Name = "PLC1" 'Add and Name Sheets
objXL.Worksheets(2).Name = "PLC2"
objXL.Worksheets(3).Name = "PLC3"
objXL.Worksheets.Add
objXL.Worksheets(4).Name = "PLC4"

objXL.Worksheets("PLC1").Select 'Format Sheet
objXL.Rows("1:1").RowHeight = 117
objXL.Rows("3:36").RowHeight = 11.25
objXL.Columns("A:A").ColumnWidth = 5
objXL.Cells(3,1).Borders(xlEdgeTop).LineStyle = xLContinuous
objXL.Cells(3,1).Borders(xlEdgeTop).Weight = xlThin
objXL.Range("A1:A35").Borders(xlEdgeRight).LineStyle = xlContinuous
objXL.Range("A1:A35").Borders(xlEdgeRight).Weight = xlThin

objXL.Cells(2,1).Value = "TAG" 'Format Column Heading
objXL.Cells(2,1).Font.Bold = True
objXL.Cells(2,1).Font.Size = 12

objXL.Range("A3:A36").Select 'Format Row 1
objXL.Selection.Font.Size = 8
objXL.Cells(3,1).Value = "I 0.0"
objXL.Cells(3,1).Select

objXL.Range("A3:A17").Autofill '***STUCK HERE*****
objXL.Cells(18,1).Value = "I 1.0"
objXL.Range("A18:A21").Autofill
objXL.Cells(22,1).Value = "Q 0.0"
objXL.Range("A22:A31").Autofill
objXL.Cells(32,1).Value = "Q 1.0"
objXL.Range("A32:A35").Autofill

objXL.ActiveWorkbook.SaveAs(folderpath & "Error Log.xls")
End Function

 
What about this ?
Const xlFillDefault = 0
objXL.Range("A3").AutoFill objXL.Range("A3:A17"), xlFillDefault

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top