
Sub SoloIperlink()
'
' SoloIperlink Macro
' Macro registrata il 01/02/2014 da MC
' Scelta rapida da tastiera Ctrl+i
'
ActiveSheet.Unprotect
Dim cls As Range
Dim valoreDaCercare As Range
Dim strLnk As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(ThisWorkbook.Path & "ACCORDI")
Set colFiles = objFolder.Files
For Each cls In Selection
Set valoreDaCercare = cls
Next
Dim pippo As String
For Each objFile In colFiles
If (InStr(objFile.Name, valoreDaCercare.Value) > 0) Then
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="ACCORDI" & objFile.Name
End If
Next
Selection.Font.Bold = True
End Sub |
Sub SoloIperlinkFrancesco()
'
' SoloIperlink Macro
' Macro registrata il 01/02/2014 da MC
' Scelta rapida da tastiera Ctrl+i
'
ActiveSheet.Unprotect
Dim cls As Range
Dim valoreDaCercare As Range
Dim CellaIntera As String
Dim strLnk As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(ThisWorkbook.Path & "ACCORDI")
Set colFiles = objFolder.Files
For Each cls In Selection
CellaIntera = cls
Set valoreDaCercare = Right(CellaIntera, 6)
Next
Dim pippo As String
For Each objFile In colFiles
If (InStr(objFile.Name, valoreDaCercare.Value) > 0) Then
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="ACCORDI" & objFile.Name
End If
Next
Selection.Font.Bold = True
End Sub |
Sub SoloIperlink()
'
' SoloIperlink Macro
' Macro registrata il 02/02/2016 da MC
'
' Scelta rapida da tastiera: CTRL+i
'
ActiveSheet.Unprotect
Dim cls As Variant
Dim valoreDaCercare As String
Dim strLnk As String
Dim Links() As String
Dim RangeImmissioneHyperlink As Range
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(ThisWorkbook.Path & "ACCORDI")
Set colfiles = objFolder.Files
scelta = InputBox("Il range contiene 1 o più celle ? (1,+)")
If scelta = 1 Then
indirizzo = InputBox("Indirizzo della cella ?")
Set RangeImmissioneHyperlink = Range(indirizzo)
Else
iniziorange = InputBox("Inizio Range?")
finerange = InputBox("Fine Range?")
Set RangeImmissioneHyperlink = Range(iniziorange & ":" & finerange)
End If
RangeImmissioneHyperlink.Select
ReDim Preserve Links(Range("b1").End(xlDown).Row)
If scelta = 1 Then
For Each cls In RangeImmissioneHyperlink
Links(1) = cls.Value
valoreDaCercare = Right(Links(1), 6)
Next
Else
If Len(finerange) > 2 And Len(finerange) = 3 Then
If Len(iniziorange) = 2 Then
For x = 1 To Right(finerange, 2) - Right(iniziorange, 1) + 1
Links(x) = Right(Range(Left(iniziorange, 1) & Right(iniziorange, 1) + x - 1), 6)
Next
Else
MsgBox ("Da implementare"): Exit Sub
End If
ElseIf Len(finerange) = 2 Then
For x = 1 To (Right(finerange, 1) - Right(iniziorange, 1) + 1)
Links(x) = Right(Range(Left(iniziorange, 1) & Right(iniziorange, 1) + x - 1), 6)
MsgBox (Links(x))
Next
Else
MsgBox ("Da implementare"): Exit Sub
End If
End If
Dim pippo As String
If scelta = 1 Then
For Each objfile In colfiles
If (InStr(objfile.Name, valoreDaCercare) > 0) Then
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add anchor:=Selection, Address:="ACCORDI" & objfile.Name
End If
Next
ElseIf Len(finerange) > 2 And Len(finerange) = 3 Then
If Len(iniziorange) = 2 Then
For Each objfile In colfiles
For Z = 1 To (Right(finerange, 2) - Right(iniziorange, 1) + 1)
If (InStr(objfile.Name, Links(Z)) > 0) Then
ActiveSheet.Range(Left(iniziorange, 1) & Right(iniziorange, 1) + Z - 1).Select
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add anchor:=Selection, Address:="ACCORDI" & objfile.Name
Selection.Font.Bold = True
End If
Next
Next
End If
ElseIf Len(finerange) = 2 Then
For Each objfile In colfiles
For Z = 1 To (Right(finerange, 1) - Right(iniziorange, 1) + 1)
If (InStr(objfile.Name, Links(Z)) > 0) Then
ActiveSheet.Range(Left(iniziorange, 1) & Right(iniziorange, 1) + Z - 1).Select
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add anchor:=Selection, Address:="ACCORDI" & objfile.Name
Selection.Font.Bold = True
End If
Next
Next
End If
End Sub |
' Macro registrata il 01/02/2014 da MC
' Scelta rapida da tastiera Ctrl+i
'
ActiveSheet.Unprotect
Dim cls As Range
Dim rangeprogressivo As Range
Dim valoredacercare As String
Dim strLnk As String
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(ThisWorkbook.Path & "ACCORDI")
Set colFiles = objFolder.Files
For Each cls In Selection
Set rangeprogressivo = cls
valoredacercare = Right(rangeprogressivo, 6)
For Each objFile In colFiles
If (InStr(objFile.Name, valoredacercare) > 0) Then
Set pluto = ActiveSheet
ActiveSheet.Hyperlinks.Add Anchor:=rangeprogressivo, Address:="ACCORDI" & objFile.Name
Exit For
End If
Next
Next
Selection.Font.Bold = True
Dim pippo As String
End Sub
|
