Get EXCEL COLUMN VB / in Array

Posted by rajivkumarnandvani on April 25, 2009

sXLpath =”C:\TESTXML\Rajiv.xls”
myArray = GetALLColumn(sXLpath)

Public function GetALLColumn(Byval  xlFilePath  )
rem define array column
Dim AllColumn()
Set ObjAppExcel = CreateObject(“Excel.Application”)
rem Disable alerts
ObjAppExcel.DisplayAlerts = False
rem Add a workbook to the Excel App
‘Get the object of the first sheet in the workbook
Set objectSheet = ObjAppExcel.Sheets(“Sheet1”)
rem count used Column in sheet
nColumnCount =objectSheet.UsedRange.Columns.Count

ReDim  preserve AllColumn(nColumnCount-1)
For i=0 to nColumnCount-1
AllColumn(i) =objectSheet.Cells(1,i+1).value


GetALLColumn =AllColumn
Set objectSheet =nothing
Set ObjAppExcel =nothing
End Function


One Response to “Get EXCEL COLUMN VB / in Array”

  1. Jeewanshu said

    hi good one
    keep it up

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: