Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi-
I have the following code. When it runs I get a "Subscript out of range" error. Can anyone clean this up for me and get me to the next sheet in the workbook? Thanks in advance for your help! For x = ActiveSheet.Index + 1 To Worksheets(Worksheets.Count).Index Range("B2").Select If ActiveCell.Value = "Distributor:" Then FUNCTION1 End If Sheets(x).Select Next x Thanks, Chris |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
No need to select
For i = ActiveSheet.Index To Worksheets.Count If UCase(Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software wrote in message ups.com... Hi- I have the following code. When it runs I get a "Subscript out of range" error. Can anyone clean this up for me and get me to the next sheet in the workbook? Thanks in advance for your help! For x = ActiveSheet.Index + 1 To Worksheets(Worksheets.Count).Index Range("B2").Select If ActiveCell.Value = "Distributor:" Then FUNCTION1 End If Sheets(x).Select Next x Thanks, Chris |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the reply Don.
This code does not move to the next sheet.... -Chris Don Guillett wrote: No need to select For i = ActiveSheet.Index To Worksheets.Count If UCase(Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software wrote in message ups.com... Hi- I have the following code. When it runs I get a "Subscript out of range" error. Can anyone clean this up for me and get me to the next sheet in the workbook? Thanks in advance for your help! For x = ActiveSheet.Index + 1 To Worksheets(Worksheets.Count).Index Range("B2").Select If ActiveCell.Value = "Distributor:" Then FUNCTION1 End If Sheets(x).Select Next x Thanks, Chris |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
OOOOOOOh MY bad!!
For i = ActiveSheet.Index To Worksheets.Count If UCase(sheets(i).Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software "Don Guillett" wrote in message ... That is correct and by design. That is because you rarely have to select to do what you want. Why waste time and effort doing that? -- Don Guillett SalesAid Software wrote in message ups.com... Thanks for the reply Don. This code does not move to the next sheet.... -Chris Don Guillett wrote: No need to select For i = ActiveSheet.Index To Worksheets.Count If UCase(Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software wrote in message ups.com... Hi- I have the following code. When it runs I get a "Subscript out of range" error. Can anyone clean this up for me and get me to the next sheet in the workbook? Thanks in advance for your help! For x = ActiveSheet.Index + 1 To Worksheets(Worksheets.Count).Index Range("B2").Select If ActiveCell.Value = "Distributor:" Then FUNCTION1 End If Sheets(x).Select Next x Thanks, Chris |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Don-
Now when I run the macro it disregards the value in "B2" and just runs the function on all sheets. The value in B2 has to be "Distributor:" in order for the function to run. Sorry for being a pain! You are helping me tremendously and I appreciate the effort! Thanks Again, Chris Don Guillett wrote: OOOOOOOh MY bad!! For i = ActiveSheet.Index To Worksheets.Count If UCase(sheets(i).Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software "Don Guillett" wrote in message ... That is correct and by design. That is because you rarely have to select to do what you want. Why waste time and effort doing that? -- Don Guillett SalesAid Software wrote in message ups.com... Thanks for the reply Don. This code does not move to the next sheet.... -Chris Don Guillett wrote: No need to select For i = ActiveSheet.Index To Worksheets.Count If UCase(Range("B2")) = "DISTRIBUTOR:" Then FUNCTION1 Next i -- Don Guillett SalesAid Software wrote in message ups.com... Hi- I have the following code. When it runs I get a "Subscript out of range" error. Can anyone clean this up for me and get me to the next sheet in the workbook? Thanks in advance for your help! For x = ActiveSheet.Index + 1 To Worksheets(Worksheets.Count).Index Range("B2").Select If ActiveCell.Value = "Distributor:" Then FUNCTION1 End If Sheets(x).Select Next x Thanks, Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Worksheet loop won't loop | Excel Programming | |||
Do loop to add a new worksheet | Excel Programming | |||
how do you loop through each worksheet? | Excel Programming | |||
worksheet loop | Excel Programming | |||
How? Macro to copy range to new worksheet, name new worksheet, loop | Excel Programming |