PC Review


Reply
Thread Tools Rate Thread

CODE 2 SELECT SHEETS LISTED IN A RANGE

 
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      30th Jul 2009
What code would select sheets that are named in the range: Sheet1!A1:A10
ignoring blanks cells, if any?

Thanx in advance.
--
Best Regards,

Faraz
 
Reply With Quote
 
 
 
 
Gary Keramidas
Guest
Posts: n/a
 
      30th Jul 2009
give this a try

Sub select_sheets()
Dim ws As Worksheet
Dim cell As Range
Set ws = Worksheets("Sheet1")
For Each cell In ws.Range("A1:A10")
On Error Resume Next
If cell.Value > "" Then
Worksheets(cell.Value).Select False
End If
On Error GoTo 0
Next
End Sub


--

Gary Keramidas
Excel 2003


"Faraz A. Qureshi" <(E-Mail Removed)> wrote in
message news:9EC243B4-B239-4566-840B-(E-Mail Removed)...
> What code would select sheets that are named in the range: Sheet1!A1:A10
> ignoring blanks cells, if any?
>
> Thanx in advance.
> --
> Best Regards,
>
> Faraz


 
Reply With Quote
 
Faraz A. Qureshi
Guest
Posts: n/a
 
      30th Jul 2009
Thanx Gary,

However, the code keeps the already active sheet to remain in the selected
one.
--
Best Regards,

Faraz


"Gary Keramidas" wrote:

> give this a try
>
> Sub select_sheets()
> Dim ws As Worksheet
> Dim cell As Range
> Set ws = Worksheets("Sheet1")
> For Each cell In ws.Range("A1:A10")
> On Error Resume Next
> If cell.Value > "" Then
> Worksheets(cell.Value).Select False
> End If
> On Error GoTo 0
> Next
> End Sub
>
>
> --
>
> Gary Keramidas
> Excel 2003
>
>
> "Faraz A. Qureshi" <(E-Mail Removed)> wrote in
> message news:9EC243B4-B239-4566-840B-(E-Mail Removed)...
> > What code would select sheets that are named in the range: Sheet1!A1:A10
> > ignoring blanks cells, if any?
> >
> > Thanx in advance.
> > --
> > Best Regards,
> >
> > Faraz

>
>

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      30th Jul 2009
kind of late here, so i'll just make this simple addition to the code

Sub select_sheets()
Dim wsname As String
Dim ws As Worksheet
Dim cell As Range
Dim cntr As Long
cntr = 0
wsname = ActiveSheet.Name
Set ws = Worksheets("Sheet1")
For Each cell In ws.Range("A1:A10")
On Error Resume Next
If cell.Value > "" Then
If cntr = 0 Then
Worksheets(cell.Value).Select
cntr = cntr + 1
ElseIf cell.Value > "" Then
Worksheets(cell.Value).Select False
End If
End If
On Error GoTo 0
Next
End Sub


--

Gary Keramidas
Excel 2003


"Faraz A. Qureshi" <(E-Mail Removed)> wrote in
message news:671F1AD0-7C57-45A6-98A0-(E-Mail Removed)...
> Thanx Gary,
>
> However, the code keeps the already active sheet to remain in the selected
> one.
> --
> Best Regards,
>
> Faraz
>
>
> "Gary Keramidas" wrote:
>
>> give this a try
>>
>> Sub select_sheets()
>> Dim ws As Worksheet
>> Dim cell As Range
>> Set ws = Worksheets("Sheet1")
>> For Each cell In ws.Range("A1:A10")
>> On Error Resume Next
>> If cell.Value > "" Then
>> Worksheets(cell.Value).Select False
>> End If
>> On Error GoTo 0
>> Next
>> End Sub
>>
>>
>> --
>>
>> Gary Keramidas
>> Excel 2003
>>
>>
>> "Faraz A. Qureshi" <(E-Mail Removed)> wrote in
>> message news:9EC243B4-B239-4566-840B-(E-Mail Removed)...
>> > What code would select sheets that are named in the range:
>> > Sheet1!A1:A10
>> > ignoring blanks cells, if any?
>> >
>> > Thanx in advance.
>> > --
>> > Best Regards,
>> >
>> > Faraz

>>
>>


 
Reply With Quote
 
MichDenis
Guest
Posts: n/a
 
      30th Jul 2009
On Error Resume Next
With WorkSheets("Sheet1")
.Activate
.Range("A1:A10").SpecialCells(xlCellTypeConstants, 23).Select
End With




"Faraz A. Qureshi" <(E-Mail Removed)> a écrit dans le message de
groupe de discussion : 9EC243B4-B239-4566-840B-(E-Mail Removed)...
What code would select sheets that are named in the range: Sheet1!A1:A10
ignoring blanks cells, if any?

Thanx in advance.
--
Best Regards,

Faraz

 
Reply With Quote
 
 
 
Reply

Thread Tools
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
CODE 2 SELECT SHEETS LISTED IN A RANGE Faraz A. Qureshi Microsoft Excel Misc 1 30th Jul 2009 07:31 AM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Microsoft Excel Discussion 6 29th Mar 2006 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Microsoft Excel Programming 6 29th Mar 2006 12:43 PM
How to repeat a code for selected sheets (or a contiguous range of sheets) in a Workbook? Dmitry Microsoft Excel Worksheet Functions 6 29th Mar 2006 12:43 PM
Select Range of sheets =?Utf-8?B?Q2Fyb2w=?= Microsoft Excel Programming 6 29th Apr 2004 02:09 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:07 PM.