Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 208
Default looping through worksheets from addin

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?


Hi
Try
For Each ws In ActiveWorkbook.Worksheets

The AddIn might be assuming you want to look at ITS sheets, not the
sheets in the ActiveWorkbook. It's usually safest to refer to the
AddIn's sheets by ThisWorkbook.Worksheets and specify
ActiveWorkbook.Worksheets for the workbook you can see.
If that doesn't fix it, your problem could be related to the variables
in your code. Are you sure they have the values you expect etc? Also,
what Range does Columns refer to, maybe there is only 1 Column??
regards
Paul


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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
looping through worksheets from addin jason Excel Programming 1 October 9th 03 01:09 PM
looping through worksheets from addin BrianB Excel Programming 0 October 9th 03 09:05 AM
looping through worksheets from addin Cliff Myers Excel Programming 0 October 9th 03 06:45 AM
looping through worksheets Alex ekster Excel Programming 1 July 21st 03 03:16 AM
looping through worksheets alex Excel Programming 0 July 20th 03 06:43 PM


All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"