WELDER ID - 301054
Friday, January 22, 2021
Friday, January 1, 2021
use of Environ("USERPROFILE") in excel vba
use of Environ("USERPROFILE") in excel vba
How to make a path as dynamic by using ENVIRON
IF path= E:\Redirect\un.singh\Desktop then I can make it dynamic BY use of vba by replacing "E:\Redirect\un.singh" with Environ("USERPROFILE") & \Desktop
one simple example is as under-
Sub hyper_link()Dim FileName, mystore As StringDim PathName As String, i As Long'AUTO SELECT USER DESKTOP NAMEPathName = Environ("USERPROFILE") & "\Desktop\ALL DRGS\"FileName = Dir(PathName & "*.pdf")Do While FileName <> vbNullStringmystore = Mid(FileName, 5, 8)On Error GoTo last:'COMPARE MYSTORE FOR ALL CELLS OF COLUMN "B"For i = 2 To 374If mystore = Left(Range("B" & i).Value, 8) ThenRange("B" & i).SelectActiveSheet.Hyperlinks.Add Range("B" & i), Address:=(PathName & FileName)Else: End IfNext i'NEXT FILE FOR MYSTOREFileName = DirLooplast:End Sub
Subscribe to:
Posts (Atom)