Automation Beyond

Testing and Test Automation for Software Quality Assurance. Above Requirements. Beyond Expectations. Methodologies and concepts. Framework Design. Programming and Scripting. Created by Albert Gareev.

Mapping Excel col names (QTP, VBScript)

Posted by Albert Gareev on 2009/05/23

Original date: 5 Dec 2008, 1:23pm


'Assumptions:
'Excel file exists
'Workbook is open (XLBook)
'Sheet exists
Set objUsedRange = XLBook.Worksheets(sSheetIndex).UsedRange()

Set objSheetColNameMap = CreateObject("Scripting.Dictionary")
For Iter = 1 To objUsedRange.Columns.Count
   sCellText = objUsedRange.Cells(1,Iter)
   If sCellText <> "" Then
      objSheetColNameMap.Item(sCellText) = Iter
   End If
Next

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>