Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 27th, 2012, 04:03 PM
Ranakhu Ranakhu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 65 Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 13 h 36 m 42 sec
Reputation Power: 14
Iterating thru cells in Excel 2010

Hello,

I am not sure why I am getting this error with line If statement in the code below...any ideas are appreciated. Get UNKNOWN RUNTIME ERROR

Code:
' do excel stuff	
Set xl = CreateObject("Excel.Application")
	
' no need to launch excel
xl.visible = False
	
' specify excel file path and name
sExcelPath = CurProjDir & "\comp_pins_nets.xlsx"	
	
'Set wb = xl.Workbooks.Open(sExcelPath)	
	
Set wb = xl.Workbooks.Open(sExcelPath, ,ReadOnly)
		
Set oCurWorkSheet = wb.Worksheets("Sheet1")
			
'Find used rows & cols
usedColsCount = oCurWorkSheet.UsedRange.Columns.Count
usedRowsCount = oCurWorkSheet.UsedRange.Rows.Count	

'Find column & row that has "Pin Name"		
For row = 0 To usedRowsCount	
   For column = 0 To usedColsCount		
     If oCurWorkSheet.Cells(row, column).Value = "Pin Name" Then
	iRow = row
	iCol = column				
    End If			
   Next			
Next

Reply With Quote
  #2  
Old February 27th, 2012, 04:33 PM
medialint's Avatar
medialint medialint is offline
Type Cast Exception
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Apr 2004
Location: OAKLAND CA | Adam's Point (Fairyland)
Posts: 14,939 medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)  Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Months 2 Weeks 2 Days 1 h 38 m 6 sec
Reputation Power: 8490
Facebook
Rows and Columns start at 1 not 0.
__________________
medialint.com

“Today you are You, that is truer than true. There is no one alive who is Youer than You.” - Dr. Seuss

Reply With Quote
  #3  
Old February 27th, 2012, 04:39 PM
Ranakhu Ranakhu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 65 Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 13 h 36 m 42 sec
Reputation Power: 14
Quote:
Originally Posted by medialint
Rows and Columns start at 1 not 0.


Thank you very much

Reply With Quote
  #4  
Old February 27th, 2012, 04:41 PM
medialint's Avatar
medialint medialint is offline
Type Cast Exception
Dev Shed God 20th Plane (14500 - 14999 posts)
 
Join Date: Apr 2004
Location: OAKLAND CA | Adam's Point (Fairyland)
Posts: 14,939 medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)medialint User rank is General 112nd Grade (Above 100000 Reputation Level)  Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1Folding Points: 319635 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 6 Months 2 Weeks 2 Days 1 h 38 m 6 sec
Reputation Power: 8490
Facebook
You could just do something like this instead of looping through the whole worksheet:

Code:
    With xl.ActiveSheet
        nRow = .Cells.Find("pin name").Row
        nCol = .Cells.Find("pin name").Column
    End With

Reply With Quote
  #5  
Old February 27th, 2012, 06:19 PM
Ranakhu Ranakhu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2009
Posts: 65 Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level)Ranakhu User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 13 h 36 m 42 sec
Reputation Power: 14
Quote:
Originally Posted by medialint
You could just do something like this instead of looping through the whole worksheet:

Code:
    With xl.ActiveSheet
        nRow = .Cells.Find("pin name").Row
        nCol = .Cells.Find("pin name").Column
    End With


Thank you again

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Iterating thru cells in Excel 2010

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap