JustCode : Loop columns in an excel sheet

This code will open up an existing excel workbook and select the active sheet then loop through the first ten cells of the first row showing the cell contents

' ****************************************
' Designed by : Smarter Dimensions
' Last Updated : 5th July 2009
' Code to loop columns in an excel sheet
' ****************************************

Dim oExcel,oWorkBook,oSheet
dim iCel,oCell,iStartCol,iEndCol

Set oExcel = createobject("Excel.Application")


oExcel.Visible = True

oWorkBook = oExcel.ActiveWorkbook

Set oSheet = oWorkBook.ActiveSheet

iStartCol = 1
iEndCol = 10

For iCel = iStartCol to iEndCol
     Set oCell = oSheet.Cells[1][iCel]

Leave a Comment

%d bloggers like this: