Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
SumProduct in VBA - Allow the user to select the file
I have the following macro:
Sub tracking() engid = "'[Export January.xls]Export_January'!$aq$2:$aq$43735" rev = "'[Export January.xls]Export_January'!$ag$2:$ag$43735" engid2 = Sheets("actual").Range("H4").Value If Not IsNumeric(engid2) Then engid2 = """" & engid2 & """" End If pct = Application.Evaluate("SUMPRODUCT(--(" & engid & "=" _ & engid2 & "),--(" & rev & "))") ThisWorkbook.Worksheets("actual").Range("AL12").Se lect Range("al12").Value = pct End Sub It works OK but, source file is hard coded. What I want to do is to allow the user to select the source file, and probably open the file (sumproduct in VBA works with closed files??? I don’t think so). I know I should include something like: Set fd = Application.FileDialog(msoFileDialogOpen) With fd ..AllowMultiSelect = False If .Show = -1 Then Set sourcebook = Workbooks.Open(Filename:=fd.SelectedItems(1)) With sourcebook….??????? ……..But how to assign to a variable the file name for the selected file, and also, how to modify the sumproduct syntax to use it??? Thanks, Cecilia |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CSV Import - user to select file | Excel Programming | |||
Macro for user to select hyperlink file | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming | |||
Prompt user to select file with default file selected dialog | Excel Programming |