Solved

What is the maximum number of columns VB Script will read

Posted on 2013-01-24
4
429 Views
Last Modified: 2013-02-08
What is the maximum number of columns VB Script will read data from? I've got a spread sheet that has data in 180 columns and it stops reading the data at the 120th column. It returns null for column 121 to 180.

sTest = Worksheets("TEST").Cells(iRow, 132)
0
Comment
Question by:jeremyzit
4 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 38816543
This is VBA (Visual Basic for Application), not VBS (VB Script), as you are inside of Excel.
And there is no limitation on columns (besides the 65535 of less recent Excel releases).

Could you prepare an example sheet with a few rows, including the code you use to read?
0
 
LVL 51

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 38817090
In the event that you are working in VBS and using automation to Excel, here's a simple example showing that columns 1 to 1000 were accessed and returned the correct values.  So there isn't a limit at 120.

Set oExcel = CreateObject("Excel.Application")
oExcel.Visible = True
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.Worksheets(1)
For iCol = 1 To 1000
   oSheet.Cells(1, iCol).Value = iCol
Next
For iCol = 1 To 1000
   sTest = oSheet.Cells(1, iCol).Value
   If sTest <> iCol Then Wscript.Echo iCol
Next
oExcel.Quit

Open in new window

~bp
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 38818444
Concur with the above.

An Excel 2003 or earlier worksheet has 256 columns, and an Excel 2007+ worksheet has 16,384 columns.

Assuming you have the right version of Excel and valid code, all columns are accessible from VBScript.
0
 

Author Comment

by:jeremyzit
ID: 38818648
I'm using Excel 2003 and it's VBA coding that I'm using since it's inside excel. I was mistaken that it was vb script. I'll try to get an example sheet put on today along with some code.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now