PDA

View Full Version : Solved: Loop in Excel



ssinghal
01-18-2007, 06:57 AM
I want to manipulate some data on all worksheets in a particular workbook except the last 6 sheets. The number of worksheets will not be constant. Could someone help with the code to do this? Thanks.

Bartek
01-18-2007, 07:02 AM
Hi,


I want to manipulate some data on all worksheets in a particular workbook except the last 6 sheets. The number of worksheets will not be constant. Could someone help with the code to do this? Thanks.

Use something like that:


For Xi=1 to Worksheets.Count - 6

'your code here for Sheets(Xi)

Next Xi

mdmackillop
01-18-2007, 07:03 AM
For i = 1 To Sheets.Count - 6
Sheets(i).Range("A1")=2
Next

ssinghal
01-18-2007, 07:09 AM
How do I make it go to the next worksheet? It is performing my action on the first sheet everytime.

mdmackillop
01-18-2007, 07:13 AM
My code should enter a value on each sheet except the last six. Can you post your code?

ssinghal
01-18-2007, 07:15 AM
I figured it out. I needed Sheet(i).Select in my code.
Thanks.