473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Converting vba(excel macro) to vbscript

2
Hi All,

Copying code from vba to vbscript did not quite work. I was hoping if anyone could give me a hand. The purpose of the code is to sort the selection so that the smallest value is on the top. I was wondering if there is a way to make this work. Thanks!

This is the original vba code.
Expand|Select|Wrap|Line Numbers
  1. Range("F1").Select
  2. Application.CutCopyMode = False
  3. ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Clear
  4.     ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Add Key:=Range("F1"), _
  5.         SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  6.     With ActiveWorkbook.Worksheets("Sheet3").Sort
  7.         .SetRange Range("F1:I49")
  8.         .Header = xlNo
  9.         .MatchCase = False
  10.         .Orientation = xlTopToBottom
  11.         .SortMethod = xlPinYin
  12.         .Apply
  13.     End With
  14.  
This is vbscript.

Expand|Select|Wrap|Line Numbers
  1. oExcel.Range("F1").Select
  2. oExcel.Application.CutCopyMode = False
  3. oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Clear
  4. oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort.SortFields.Add Key:=Range("F1"), _
  5.         SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
  6.     With oExcel.ActiveWorkbook.Worksheets("Sheet3").Sort
  7.         .SetRange Range("F1:I49")
  8.         .Header = xlNo
  9.         .MatchCase = False
  10.         .Orientation = xlTopToBottom
  11.         .SortMethod = xlPinYin
  12.         .Apply
  13.     End With
  14.  
The vbs script has a "bad index" error starting on line 3.

With Best Regards,
Suggz
Mar 9 '12 #1
0 1292

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mrs Howl | last post by:
I don't know if there's even a way to do what I want. I click on a button in an Access form, and it opens an instance of Excel, and opens a workbook and runs a macro that's in it. So far, fine,...
3
by: maryam | last post by:
Hi i have some data in excel....I want to perform a series of operations on them and output the results to excel again. I know that some stuff could be used with VBA. however in this special case...
1
by: jdoverton | last post by:
Hey, I routinely import an Excel file, operate on several columns and export it as a separate file. I need to be able to run an Excel Macro from my Access VBA. Any Suggestions?/ Thanks...
1
by: omar07266742 | last post by:
Hi, How can I run an excel macro using access macros?. Any suggestion without using VBA? Regards Omar
0
by: kittu513 | last post by:
Hi I need some help regarding the alignment of the value in the active cell. my code is like this (its VB code to implement an Excel macro) Range("B1").Select ActiveCell.Offset(50,...
7
by: NeverLift | last post by:
This is probably answered elsewhere, but I've searched the Web and VBA for Excel manual, find no answers. I have a VBA-coded macro in an Excel workbook that is to open another existing workbook --...
4
NarenMCA
by: NarenMCA | last post by:
Hi, I want to use status bar control 6.0 in VBA(Excel). Other functions in the Macro will be performing some copy/paste and filtering operations. I want the progress bar to show status based on...
1
by: dhruvbhatt | last post by:
I am all new for vba excel project. i already have the code ready. I want to have a gui for this. meaning, all macros have been coded for the excel sheet. Now i want to build GUI for which there...
1
MitchR
by: MitchR | last post by:
Good Morning Folks; I have a question that is pretty far fetched but here goes nothing... I am looking to find a way to insert a macro into an Excel command button located in an Access VBA...
1
by: chanshaw | last post by:
I hope this is the right forum for this (if not let me know where i should have posted this) Alright I'm having a little trouble passing some arguments to a function and then having it return what I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.