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

VBScript Used Range

Status
Not open for further replies.

busy_bee

Programmer
Oct 9, 2020
14
0
0
US
I have the following VBScript code.

Code:
lastRow = editWorkbook.Sheets(sheetName).UsedRange.Rows.Count
lastColumn = editWorkbook.Sheets(sheetName).UsedRange.Columns.Count

WScript.Echo ("Last row:" & CStr(lastRow))
WScript.Echo ("Last column:" & CStr(lastColumn))
WScript.Echo("Value:" & CStr(editWorkbook.Sheets(sheetName).Cells(lastRow,lastColumn).Value))

It is giving me as output
Last row: 1048458
Last column: 30
Value:

I have no data in the above mentioned cell. My last row with data is in row 187, last column:J

Why am I getting such an output? I would appreciate help in resolving this.

 
Hi,

Data in an Excel sheet can be more than text an numbers.

You might have SPACE character(s) or unprintable character(s), for instance.

SELECT every ROW below Row 187 and right-click DELETE.

SELECT every COLUMN the the right of Column J and right-click DELETE.

Then run your procedure.

Keep your sheets clean thusly.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top