Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
For each... next (to act on each worksheet)
I want my VB application to go through each sheet, check the value in a cell,
and re-name the worksheet according to the value in the cell. I tried using a "For Each... Next" loop, but VB didn't like using this with "Sheet" and "ActiveWorkbook" objects. For Each Sheet In ActiveWorkbook Select Case Range("A3").Value Case "aaaa": ActiveSheet.Name = "Company A" Case "bbbb": ActiveSheet.Name = "Company B" End Select Next Sheet How can I make this work, or structure another loop to do the same action? Any help is greatly appreciated. Rgds, Dan Winterton |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
For each... next (to act on each worksheet)
Try:
Sheet.Name Rather than: ActiveSheet.Name Regards Trevor "Dan Winterton" wrote in message ... I want my VB application to go through each sheet, check the value in a cell, and re-name the worksheet according to the value in the cell. I tried using a "For Each... Next" loop, but VB didn't like using this with "Sheet" and "ActiveWorkbook" objects. For Each Sheet In ActiveWorkbook Select Case Range("A3").Value Case "aaaa": ActiveSheet.Name = "Company A" Case "bbbb": ActiveSheet.Name = "Company B" End Select Next Sheet How can I make this work, or structure another loop to do the same action? Any help is greatly appreciated. Rgds, Dan Winterton |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
For each... next (to act on each worksheet)
Hi Dan,
Could it be: Dim mySheet As Worksheet For Each mySheet In ActiveWorkbook.Worksheets Select Case Range("A3").Value Case "aaaa" mySheet.Name = "Company A" Case "bbbb" mySheet.Name = "Company B" End Select Next I tried Trevors approach ... no go. Frans "Dan Winterton" schreef in bericht ... I want my VB application to go through each sheet, check the value in a cell, and re-name the worksheet according to the value in the cell. I tried using a "For Each... Next" loop, but VB didn't like using this with "Sheet" and "ActiveWorkbook" objects. For Each Sheet In ActiveWorkbook Select Case Range("A3").Value Case "aaaa": ActiveSheet.Name = "Company A" Case "bbbb": ActiveSheet.Name = "Company B" End Select Next Sheet How can I make this work, or structure another loop to do the same action? Any help is greatly appreciated. Rgds, Dan Winterton |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
automatically appending newly added data on worksheet to a master list worksheet | Links and Linking in Excel | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Excel Discussion (Misc queries) | |||
plot graph from multiple worksheet as embedded chart object on every worksheet | Excel Worksheet Functions | |||
Upload multiple text files into 1 excel worksheet + put the filename as the first column in the worksheet | Excel Worksheet Functions | |||
Attaching a JET database to an Excel Worksheet OR storing large binary data in a worksheet | Excel Programming |