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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need to convert VBA code into Vb script

Status
Not open for further replies.

Baskar53

Programmer
Jun 7, 2019
2
US
Hi,

i'm new to vbscript can help me this vba code how to convert into vb script.
Sub Macro2()
'
' Macro2 Macro
'

'
'Selection.End(xlDown).Select
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Selection.Delete Shift:=xlToLeft
Range("A2").Select
End Sub
 
Code:
' Create an excel object
set xlobj = CreateObject('Excel.Application')

' Use the xlobj for all the excel commands
with xlobj
    .Range("A" & Rows.Count).End(xlUp).Offset(1).Select
    .Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
    .Selection.Delete Shift:=xlToLeft
    .Range("A2").Select
end

' Close the object if you need to
xlobj.Close
set xlobj = nothing
 
For xwb's code to work you will also need to declare:

Code:
[blue]Const xlUp = -4162 [green]'(&HFFFFEFBE)[/green]
Const xlToLeft = -4159 [green]'(&HFFFFEFC1)[/green]
Const xlLastCell = 11[/blue]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top