sassora
12-03-2008, 06:51 AM
Hi,
I am using the folder picker in Excel to output the path selected on the spreadsheet. This seems to work fine most of the time but if I find a few paths in succession then. A cell way down the page in column D is activated. Any ideas why?
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'If user is double clicking in column D then run GetFolder macro
If Target.Column = 4 Then GetFolder
End Sub
Sub GetFolder()
'Ensure cells are not "active"
Range("D" & ActiveCell.Row).Select
ChDir "C:\"
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
Range("E" & ActiveCell.Row).Value = .SelectedItems(1)
Range("E" & ActiveCell.Row).Select
ActiveCell.Hyperlinks.Add ActiveCell, .SelectedItems(1)
End If
Range("E" & ActiveCell.Row).Select
End With
End Sub
I am using the folder picker in Excel to output the path selected on the spreadsheet. This seems to work fine most of the time but if I find a few paths in succession then. A cell way down the page in column D is activated. Any ideas why?
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'If user is double clicking in column D then run GetFolder macro
If Target.Column = 4 Then GetFolder
End Sub
Sub GetFolder()
'Ensure cells are not "active"
Range("D" & ActiveCell.Row).Select
ChDir "C:\"
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = False
If .Show = -1 Then
Range("E" & ActiveCell.Row).Value = .SelectedItems(1)
Range("E" & ActiveCell.Row).Select
ActiveCell.Hyperlinks.Add ActiveCell, .SelectedItems(1)
End If
Range("E" & ActiveCell.Row).Select
End With
End Sub