Code to get Colomn count and Name of a Excell File

0
17
Spread the love
  • 3
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    3
    Shares

Here is a simple piece of code that will give you the column.
Most of time I need row count but not the column count.But this time I need the column count.
I need to check the required number of column . If the number matches then I need to test if the particular column exists or not.


Lets check the code

Public Function GetColCount (sSheetName)
On Error Resume Next
Do
i = i + 1
sColName = DataTable.GetSheet(sSheetName).GetParameter(i).Name
Loop While 0 = Err.Number
‘GetParameter throws an error when using an index that is out of bounds …
‘We can use this functionality to ASSUME that it’s an unused column.
‘We’ve come to the end of our USED columns
GetColCount = i – 1
On Error GoTo 0
End Function





Now it is your task to find out name of the coloumn.
lets see who can do it.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 3
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    3
    Shares

LEAVE A REPLY

Please enter your comment!
Please enter your name here