Andreas Hermle
asked on
Prompt user to enter a column letter using VBA
Dear Experts:
Below Code converts Path Entries in Column 'B' to Hyperlinks. The macro works just great.
Could somebody help me to tweak this code in the following way:
The path entries could be in any column and I do not want to hard code the macro every time the column letter changes (the macro is activated also by other people)
An Input Box is to prompt the user to enter the column letter and then the macro runs.
Only single column letters are allowed, i.e. A till Z. Any other caracter that is entered (numbers, alphanumeric entries, space(s) etc) will trigger an error.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Below Code converts Path Entries in Column 'B' to Hyperlinks. The macro works just great.
Could somebody help me to tweak this code in the following way:
The path entries could be in any column and I do not want to hard code the macro every time the column letter changes (the macro is activated also by other people)
An Input Box is to prompt the user to enter the column letter and then the macro runs.
Only single column letters are allowed, i.e. A till Z. Any other caracter that is entered (numbers, alphanumeric entries, space(s) etc) will trigger an error.
Help is much appreciated. Thank you very much in advance.
Regards, Andreas
Sub Convert_Path_To_Hyperlinks()
Dim r As Range
Dim MyValue As String
On Error Resume Next
For Each r In Range("B2", Range("B2").End(xlDown))
If r.Value <> "" Then
MyValue = r.Value
Range(r.Address).Select
ActiveSheet.Hyperlinks.Add Anchor:=Excel.Selection, Address:=MyValue, TextToDisplay:=MyValue
End If
Next r
Range("a1").Select
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Regards, Andreas