Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default 'For Loop' For Selected Sheets/As Named In A Range

Could one of you experts kindly provide a sample code so as to determine how
to carry out an exercise of "For Loop" in the following cases?

For Each "sheet in the selected sheets"
....
....
Next

and

For Each "sheet with name listed in a range (e.g. Sheet1!A1:A10)"
....
....
Next

Thanx in advance

--
Best Regards,

Faraz
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 'For Loop' For Selected Sheets/As Named In A Range


Don,

If it is the OP gets a lot of homework judging by the 800+ previous posts!!!

Mike

"Don Guillett" wrote:

Homework?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Faraz A. Qureshi" wrote in
message ...
Could one of you experts kindly provide a sample code so as to determine
how
to carry out an exercise of "For Loop" in the following cases?

For Each "sheet in the selected sheets"
...
...
Next

and

For Each "sheet with name listed in a range (e.g. Sheet1!A1:A10)"
...
...
Next

Thanx in advance

--
Best Regards,

Faraz



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default 'For Loop' For Selected Sheets/As Named In A Range


Hi,

Try these

Sub LoopSelected()
Dim sh As Worksheet
For Each sh In ThisWorkbook.Windows(1).SelectedSheets
MsgBox sh.Name ' do your stuff here
Next sh
End Sub


Sub LoopSelected2()
For Each c In Range("A1:A3")
MsgBox Sheets(c.Value).Name ' do your stuff here
Next
End Sub

Mike

"Faraz A. Qureshi" wrote:

Could one of you experts kindly provide a sample code so as to determine how
to carry out an exercise of "For Loop" in the following cases?

For Each "sheet in the selected sheets"
...
...
Next

and

For Each "sheet with name listed in a range (e.g. Sheet1!A1:A10)"
...
...
Next

Thanx in advance

--
Best Regards,

Faraz



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 'For Loop' For Selected Sheets/As Named In A Range


Hi Faraz

'Loop for selected sheets
For Each shtemp In ActiveWindow.SelectedSheets
MsgBox shtemp.Name
Next


'Loop with sheets mentioned in range
For Each shtemp In ActiveWorkbook.Sheets
If WorksheetFunction.CountIf(Range("A1:A10"), _
shtemp.Name) 0 Then
MsgBox shtemp.Name
End If
Next

If this post helps click Yes
---------------
Jacob Skaria


"Faraz A. Qureshi" wrote:

Could one of you experts kindly provide a sample code so as to determine how
to carry out an exercise of "For Loop" in the following cases?

For Each "sheet in the selected sheets"
...
...
Next

and

For Each "sheet with name listed in a range (e.g. Sheet1!A1:A10)"
...
...
Next

Thanx in advance

--
Best Regards,

Faraz

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
Loop Until out of named range [email protected] Excel Programming 5 April 3rd 07 05:34 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Worksheet Functions 6 March 29th 06 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Excel Programming 6 March 29th 06 12:43 PM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
a for selected sheets print named page macro Todd Excel Programming 1 July 22nd 04 12:25 AM


All times are GMT +1. The time now is 01:36 PM.

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

About Us

"It's about Microsoft Excel"