View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
R Kalal R Kalal is offline
external usenet poster
 
Posts: 4
Default Iterating through Cells .Net/Excel 2003

From VB.Net(2003) I want to be able to iterate through all cells "c", in a
runtime defined range object(excel 2003). However, when the xTest sub is
run, it generates a member not found error on the line( for each c in
objrange.cells).

Any help would be greatly appreciated.



Thanks Rick

declarations

Private objExcel As Microsoft.Office.Interop.Excel.Application

Private objWorkbook As Microsoft.Office.Interop.Excel.Workbook

Private objRange As Microsoft.Office.Interop.Excel.Range



function xTest(strSomeRange as string) as variant

Dim c As object

objExcel = New Microsoft.Office.Interop.Excel.Application

objExcel.Visible = True

objWorkbook = objExcel.Workbooks.Add()

objRange = objWorkbook.ActiveSheet.Range(strSomeRange)



For Each c In objRange.Cells ' this is where the error occurs.

'some code goes here and sets a format based on the cells content

Next c

End Sub