From: OldDog on 16 Apr 2010 12:11 How would I convert this macro to vbScript? Sub Macro1() ' ' Macro1 Macro ' Range("AQ157").Select Selection.End(xlDown).Select Range(Selection, Selection.End(xlDown)).Select End Sub So far I have xl.cells("AQ157").Select xl.Selection.End(xlDown).Select 'This is the line I am having problems with: xl.Range(Selection, Selection.End(xlDown)).Select 'This is the error: ' Microsoft VBScript runtime error: Object required: 'Selection' TIA, OldDog
From: Tom Lavedas on 16 Apr 2010 16:33 On Apr 16, 12:11 pm, OldDog <mikef2...(a)comcast.net> wrote: > How would I convert this macro to vbScript? > > Sub Macro1() > ' > ' Macro1 Macro > ' > Range("AQ157").Select > Selection.End(xlDown).Select > Range(Selection, Selection.End(xlDown)).Select > End Sub > > So far I have > > xl.cells("AQ157").Select > xl.Selection.End(xlDown).Select > > 'This is the line I am having problems with: > xl.Range(Selection, Selection.End(xlDown)).Select > 'This is the error: > ' Microsoft VBScript runtime error: Object required: 'Selection' > > TIA, > > OldDog Something like this, I think (though I haven't analyzed what it is supposed to accomplish, exactly - just addressed the syntax issue) ... Const xlDown = -4121 xl.cells("AQ157").End(xlDown).Select xl.Range(xl.Selection, xl.Selection.End(xlDown)).Select _____________________ Tom Lavedas
From: Reventlov on 16 Apr 2010 16:48 Il giorno Fri, 16 Apr 2010 13:33:51 -0700 (PDT), Tom Lavedas <tglbatch(a)verizon.net> ha scritto: >Something like this, I think (though I haven't analyzed what it is >supposed to accomplish, exactly - just addressed the syntax issue) ... > >Const xlDown =3D -4121 > xl.cells("AQ157").End(xlDown).Select > xl.Range(xl.Selection, xl.Selection.End(xlDown)).Select Obviously (?) at the top "XL" should be declared set xl=createobject("excel.application") This is useful as far as he is stuck on the "selection object required". -- Giovanni Cenati (Bergamo, Italy) Write to "Reventlov" at katamail com http://digilander.libero.it/Cenati (Esempi e programmi in VbScript) --
From: OldDog on 19 Apr 2010 11:31 On Apr 16, 1:48 pm, no...(a)no.void (Reventlov) wrote: > Il giorno Fri, 16 Apr 2010 13:33:51 -0700 (PDT), Tom Lavedas <tglba...(a)verizon.net> ha > scritto: > > >Something like this, I think (though I haven't analyzed what it is > >supposed to accomplish, exactly - just addressed the syntax issue) ... > > >Const xlDown =3D -4121 > > xl.cells("AQ157").End(xlDown).Select > > xl.Range(xl.Selection, xl.Selection.End(xlDown)).Select > > Obviously (?) at the top "XL" should be declared > set xl=createobject("excel.application") > This is useful as far as he is stuck on the "selection object required". > > -- > Giovanni Cenati (Bergamo, Italy) > Write to "Reventlov" at katamail comhttp://digilander.libero.it/Cenati(Esempi e programmi in VbScript) > -- I gave the code a try and I get this err: E:\Scripts\VBS\Test_Find.vbs(37, 2) Microsoft VBScript runtime error: Unknown runtime error Here is my script so far: Const ForReading = 1 Const xlCellTypeLastCell = 11 Const xlFormulas = -4123 Const xlPart = 2 Const xlByRows = 1 Const xlNext = 1 Const xlDown = -4121 strPath = Replace(WScript.ScriptFullName, WScript.ScriptName, "") & "test.xls" boolMatchCase = False Set xl = CreateObject("Excel.Application") xl.Visible = True xl.DisplayAlerts = FALSE Set wb = xl.Workbooks.Open(strPath) Set ws1 = wb.Worksheets(1) Set ws2 = wb.Worksheets(2) ws1.Activate Set objRange = ws1.UsedRange objRange.SpecialCells(xlCellTypeLastCell).Activate intNewRow = XL.ActiveCell.Row + 1 strNewCell = "A" & intNewRow Set mainRng = ws1.UsedRange.Cells ColCount = mainRng.Columns.Count RowCount = mainRng.Rows.Count For R = 1 To mainRng.Rows.Count For C = 1 To mainRng.Columns.Count If ws1.Cells(R,C).Value = "IsInstalled" Then ws1.Cells(R,C).Select wscript.echo R & vbTab & C xl.cells("AQ157").End(xlDown).Select '< -- this is line 37 xl.Range(xl.Selection, xl.Selection.End(xlDown)).Select End If '< ----- end script Eventually I want to replace ("AQ157") with (R,C)
|
Pages: 1 Prev: HTA: error in this.offset Next: Beginning scripting and have a problem |