VBA sui "NOMI" celle

Versione Completa   Stampa   Cerca   Utenti   Iscriviti     Condividi : FacebookTwitter
ABCDEF@Excel
00sabato 31 ottobre 2020 03:33
Ciao a tutti,
non riesco prendere il nome del foglio e l'indirizzo delle celle con "NOME". Dove sbaglio?
Grazie mille
federico460
00sabato 31 ottobre 2020 09:03
ciao
non penso sia quello che vuoi
ma ci provo

Sub A()
Dim wk As Workbook
Dim n As Name, rg, f
f = "Foglio1"
Set wk = ThisWorkbook
Range("A1:D4") = ""
With wk
For Each n In .Names
rg = rg + 1
Cells(rg, 1) = n.Name
Cells(rg, 2) = .Names(n.Name)
'MsgBox .Names(n.Name).RefersTo
'MsgBox .Names(n.Name)
'If InStr(n.RefersTo, "#REF") Then n.delete
If ActiveSheet.Name = f Then Cells(rg, 3) = ActiveSheet.Name
If ActiveSheet.Name = f Then Cells(rg, 4) = Right(Cells(rg, 2), Len(Cells(rg, 2)) - Len(Cells(rg, 3)) - 2)
Next
End With
End Sub

by sal
00sabato 31 ottobre 2020 11:00
Ciao Prova cosi. se ho capito bene

Sub A()
Dim wk As Workbook
Dim n As Name, rg, f
f = "Foglio1"
Set wk = ThisWorkbook
Range("A1:B4") = ""
With wk
    For Each n In .Names
        rg = rg + 1
        Cells(rg, 1) = n.Name
        Cells(rg, 2) = .Names(n.Name)
        'MsgBox .Names(n.Name).RefersTo
        'MsgBox .Names(n.Name)
        'If InStr(n.RefersTo, "#REF") Then n.delete
        If Mid(.Names(n.Name), 2, InStr(.Names(n.Name), "!") - 2) = f Then Cells(rg, 3) = Mid(.Names(n.Name), 2, InStr(.Names(n.Name), "!") - 2)
        If Mid(.Names(n.Name), 2, InStr(.Names(n.Name), "!") - 2) = f Then Cells(rg, 4) = Mid(.Names(n.Name), 10)
    Next
End With
End Sub


Ciao By sal (8-D
ABCDEF@Excel
00sabato 31 ottobre 2020 11:19
@federico460
Grazie. Mi riferivo hai NOMI delle celle, mi ero dimenticato di mettere il segno =
f = "=Foglio1"

@By sal
Grazie meglio il Tuo. Mi chiedevo del "perchè" e ho notato che parti dal 2° carattere
If Mid(.Names(n.Name), 1, InStr(.Names(n.Name), "!") - 1) = f Then Cells(rg, 3) = Mid(.Names(n.Name), 2, InStr(.Names(n.Name), "!") - 2)
If Mid(.Names(n.Name), 1, InStr(.Names(n.Name), "!") - 1) = f Then Cells(rg, 4) = Mid(.Names(n.Name), InStr(.Names(n.Name), "!") + 1, 10)

Questa è la versione 'lo-fi' del Forum Per visualizzare la versione completa clicca qui
Tutti gli orari sono GMT+01:00. Adesso sono le 00:34.
Copyright © 2000-2024 FFZ srl - www.freeforumzone.com