ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping through worksheets from addin (https://www.excelbanter.com/excel-programming/279131-re-looping-through-worksheets-addin.html)

jason

looping through worksheets from addin
 
Is it looking at the addin's worksheets by any chance?
Does the add-in definitely specify the code to look at the worksheets
in the activeworkbook (rather than Thisworkbook)?

J

strataguru wrote in message ...
I am trying to loop through all the worksheets from an addin.

When I created my addin - I had only one worksheet - Sheet1 - which I
didn't care about. Whereas, the workbook I'm running the addin against
has 10 worksheets.

When I execute the following:
For Each ws In Worksheets
If ws.Name < "Trans" Then
For i = 1 To Columns.Count
If (ws.Cells(1, i).Value) = caseNumText Then
ws.Cells(Target.Row, i).Value = caseNum
ElseIf (ws.Cells(1, i).Value) = debtorIDText Then
ws.Cells(Target.Row, i).Value = DebtorID
End If
Next i
End If
Next ws
***********
The loop looks in Sheet1 - then exits .... it never gets into the
worksheets in the workbook.

What piece am I missing?
Thanks!



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


strataguru[_6_]

looping through worksheets from addin
 
think i got it with the following:


Private Sub XLapp_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
' code
For Each ws In Sh.Parent.Worksheets

' code

Next ws
End Sub

Thanks for the pointers!
-Robin



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



All times are GMT +1. The time now is 07:33 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com