| |
jennyd
Posts: 6
Score: 0
Joined: 6/1/2001
From: USA
Status: offline
|
I am going to give this one more try. I am having some difficulty with determining the line of code that will allow me to insert a new row above the currently selected cell. The code created when you record a macro and do this manually will not work when transported to VBScript. Here is a snippet of code, with the offending line bolded in red. Set oEx = GetObject("","Excel.Application") oEx.Visible = true oEx.Workbooks.open "C:\test.xls" Set oWS = oEx.ActiveWorkbook.Sheets("Sheet1") oWS.Activate Toprow = 1 Bottomrow = 8 For i = Toprow to Bottomrow oWS.Range("a1").Offset(i,0).Select If oWS.Range("a1").Offset(i+1,0) <> "" Then oWS.Selection.EntireRow.Insert oWS.Range("a1").Offset(i,0).Select End If oWS.Range("a1").Offset(i,0) = "Stuff" & i oWS.Range("a1").Offset(i,1) = "More Stuff" & i Next Try this on a simple sheet with any data in cell A1 and in A5 and the rest empty. Desperately wanting an approach!!!
|
|