
for i=0 to 11
label = "Sheet" & numero + i
set foglio = label ---> Debug!!!!!
foglio.Name = "Anno" & i
next i |
For i = 1 To Sheets.Count
Sheets(i).Name = Sheets(i).Range("a1")
Next |
Option Explicit
Sub codenameonon()
Dim ws As Worksheet
Dim i As Long
For Each ws In ThisWorkbook.Worksheets
For i = 1 To ThisWorkbook.Worksheets.Count
If ws.CodeName = "Foglio" & i Then
ws.Name = ws.Cells(1, 1) 'qui l'azione da svolgere
Exit For
End If
Next i
Next ws
End Sub
|
Sub test()
data = Sheet1.Cells(1, 1) 'resta fissa
For i = 0 To 11
Worksheets("Anno" & i).Name = "test anno" & i
Next i
End Sub
Sub test2()
data = Sheet1.Cells(1, 1) 'resta fissa
For i = 0 To 11
nomeSheet = "Sheet" & i
nomeSheet.Name = "test anno" & i
Next i
End Sub
|
Sheets(1).Name
Sheets("Foglio1").Name
Foglio1.Name
Sheets(1).CodeName
Sheets("Foglio1").CodeName
Foglio1.CodeName
Sheets(1).Name
Foglio1.Name
Sheets(1).CodeName
Foglio1.CodeName
foglio1.Parent.VBProject.VBComponents(foglio2.CodeName).Name = "MyNewCodeName" |
foglio1.Parent.VBProject.VBComponents(foglio1.CodeName).Name = "MyNewCodeName" |
Option Explicit
Sub test2()
Dim data as date, i as integer, nomesheet as worksheet
data = Foglio1.Cells(1, 1) 'resta fissa
For i = 1 To 12
Set nomesheet = Sheets(i)
nomesheet.Name = "test anno" & i
Next i
End Sub |
Sub test()
option explicit
dim lastrundate as date, numero as double, i as double
lastrundate = Sheet1.Cells(2, 47).value
Dim label As String
numero = 33
i = 0
'---------------Nomi Fogli Anno------------------------
For Each ws In ThisWorkbook.Worksheets
Set foglio = ws
If ws.CodeName = "Sheet" & numero Then
cmt = Switch(i < 4, "pippo", i >= 4 And i < 8, "pluto", i >= 8, "paperino")
'--anno-----
If i = 0 Or i = 4 Or i = 8 Then anno = 0
If i = 1 Or i = 5 Or i = 9 Then anno = 1
If i = 2 Or i = 6 Or i = 10 Then anno = 2
If i = 3 Or i = 7 Or i = 11 Then anno = 3
'-----------
label = cmt & " Report Sell-Buy " & Year(lastrundate) + anno
ws.Name = label
numero = numero + 1
i = i + 1
End If
Next ws
End Sub
|
anno = i mod 4
Option Explicit
Sub test_select()
Dim a As Integer, m As String
a = InputBox("Enter a number [1-3]:")
Select Case a
Case 1
m = "Hai inserito 1 " & (1 / 0)
Case 2
m = "Hai inserito 2"
Case 3
m = "Hai inserito 3"
Case Else
m = "Non hai inserito un numero tra 1 e 3."
End Select
MsgBox m
End Sub
Sub test_switch()
Dim a As Integer, m As String
a = InputBox("Enter a number [1-3]:")
If a Like "[!1-3]" Then
m = "Non hai inserito un numero tra 1 e 3."
Else
m = Switch(a = 1, "Hai inserito 1 " & (1 / 0), a = 2, "Hai inserito 2", a = 3, "Hai inserito 3")
End If
MsgBox m
End Sub
|
