# Thread: How to obtain how many columns of data a row has?

1. ## How to obtain how many columns of data a row has?

In this scenario I know which row I am using within excel. Let's say row 5.

Now in my excel there are 11 columns. Some rows have data in all columns and some do not. So for row 5 there maybe 6 columns of data.

I want to use the data from a range of Columns assocaited with Row 5 and keep getting the data until I reach a column with a blank cell.

I was thinking about using a For Loop and a Dynamic Array.

The data I am gathering from excel are names of Tabs on a web page. I want to pull the data and verify those tabs and names are really on the web page.

I will also need to know the number of columns that has valid data for that particular row.

Any ideas how I can do this?

Thanks!
SBsteve

2. ## Re: How to obtain how many columns of data a row has?

You can try something like this:

for i=1 to numRowCount
'assuming data is loaded to datasheet from Execel
for j=1 to 20'you can store this max value in a variable too
x=Trim(datatable.getCelldata(i,j))'i.e 1st row 1st col
if x&lt;&gt;""
tab&amp;j=x
Else
Exit for
Next
Next

3. ## Re: How to obtain how many columns of data a row has?

Thanks Vasuk.

Curious, you have numRowCount. In my case I don't care about how many rows there are, cause I know I am dealing with a specfic row. What I want is a column count.

Can I use this:

numColumnCount

SBsteve

4. ## Re: How to obtain how many columns of data a row has?

Vasuk,

I modified your code a bit, but now I am getting an "Expected end of statement" error.

================================================== ========

for i=1 to numRowCount
for j=1 to numColumnCount
x=Trim(datatable.getCelldata(i,j))'i.e 1st row 1st col
If x&lt;&gt;"" Then
tab&amp;j=x
msgbox i
msgbox j
msgbox x
Else
Exit for
End If
Next
Next

==========================================

SBsteve

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 09:02 AM.

Copyright BetaSoft Inc.