Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through a range

It has been a very long time since I have programmed in Excel. I've got the
general idea, but I'm missing something.

Here's the situation:
I have a information in 2 columns A and B
In column A, if there is something, it is a Worksheet name in the workbook
In column B will be YES or NO indicating whether I should hide the worksheet
or not

Conceptually I know what to do, but I'm struggling with the right commands
and properties.

First I will not know the number of entries -- but I can assume they will
be less 150
I know I want to loop through column B, and if there is a YES, then I should
hide the worksheet that has the name in that row, column B

I thought I had it -- but I'm getting an error. I know this is very simple

sub test()
Dim Rng As Range
Dim Wksname As Worksheet
Dim i As Integer

Sheets("CONTROLLER").Select
Set Rng = Range("A3")
For Each Sheet In Rng
If Rng.Offset(i, 1).Value = "YES" Then <<<< ERROR OCCURS HERE?
Wksname = Rng.Offset(i, 0).Value
If Wksname.Visible = xlSheetVisible Then Wksname.Visible =
xlSheetHidden
End If
i = i + 1
Next Sheet
End Sub

I appreciate the hint
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default Looping through a range

UNtested

sub doit()
mc=1
with sheets("Controller")
for i=.cells(rows.count,mc).end(xlup).row to 2
if ucase(.cells(i,2))="YES" then sheets(.cells(i,1)).visible=xlveryhidden
end with
next i
end sub

Sheets("CONTROLLER").Select
Set Rng = Range("A3")
For Each Sheet In Rng
If Rng.Offset(i, 1).Value = "YES" Then <<<< ERROR OCCURS HERE?
Wksname = Rng.Offset(i, 0).Value
If Wksname.Visible = xlSheetVisible Then Wksname.Visible =
xlSheetHidden
End If
i = i + 1
Next Sheet
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Taylorpk" wrote in message
...
It has been a very long time since I have programmed in Excel. I've got
the
general idea, but I'm missing something.

Here's the situation:
I have a information in 2 columns A and B
In column A, if there is something, it is a Worksheet name in the workbook
In column B will be YES or NO indicating whether I should hide the
worksheet
or not

Conceptually I know what to do, but I'm struggling with the right commands
and properties.

First I will not know the number of entries -- but I can assume they will
be less 150
I know I want to loop through column B, and if there is a YES, then I
should
hide the worksheet that has the name in that row, column B

I thought I had it -- but I'm getting an error. I know this is very simple

sub test()
Dim Rng As Range
Dim Wksname As Worksheet
Dim i As Integer

Sheets("CONTROLLER").Select
Set Rng = Range("A3")
For Each Sheet In Rng
If Rng.Offset(i, 1).Value = "YES" Then <<<< ERROR OCCURS HERE?
Wksname = Rng.Offset(i, 0).Value
If Wksname.Visible = xlSheetVisible Then Wksname.Visible =
xlSheetHidden
End If
i = i + 1
Next Sheet
End Sub

I appreciate the hint


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
Copying Range Based On Certain Criteria? Possible looping through the Range Big H Excel Programming 1 October 27th 06 03:32 AM
Determine if range has NO Blank Cells without looping through each cell in range Excelenator[_29_] Excel Programming 4 August 4th 06 06:30 AM
Looping in a range Robert Excel Programming 3 April 24th 06 06:09 AM
Looping through a range Shawn[_10_] Excel Programming 2 October 3rd 05 08:51 PM
looping through a range Jo[_6_] Excel Programming 1 October 21st 03 11:11 PM


All times are GMT +1. The time now is 11:18 AM.

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"