Rename and move to next sheet

ekrengel
04-13-2008, 03:15 PM
Does anyone know the proper way to rename the current sheet, and move to the next one for "VBscript"? I thought that this would work...but it isn't working properly. It renames the first sheet but doesn't go past the second.

intSheet = 1 'counter for sheets

objExcel.Sheets("Sheet" & intSheet).Select 'select current sheet
objExcel.Sheets("Sheet" & intSheet).Name = strComputer 'rename current sheet as the computername

intSheet = intSheet + 1 'counter to add next sheet

objExcel.Sheets("Sheet" & intSheet).Select 'go to the next sheet

Heyjoe
04-13-2008, 04:45 PM
I can't diagnose your problem because you don't show your loop. I suspect that the following statement: "intSheet = 1 'counter for sheets" many be inside the loop. If so it will keep resetting its value to 1 and therefore the highest value you can get is 2.

ekrengel
04-13-2008, 05:05 PM
Yes! That was the problem, thank you!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum