Re: Using Sub RDB_Merge_Data()

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi Ladymuck

You can use the add-in
http://www.rondebruin.nl/merge.htm

Or add browse code (untested)
For others example workbook is on this page
http://www.rondebruin.nl/fso.htm

Sub RDB_Merge_Data()
Dim myFiles As Variant
Dim myCountOfFiles As Long
Dim oApp As Object
Dim oFolder As Variant

Set oApp = CreateObject("Shell.Application")

'Browse to the folder
Set oFolder = oApp.BrowseForFolder(0, "Select folder", 512)
If Not oFolder Is Nothing Then

myCountOfFiles = Get_File_Names( _
MyPath:=oFolder.Self.Path, _
Subfolders:=False, _
ExtStr:="*.xl*", _
myReturnedFiles:=myFiles)

If myCountOfFiles = 0 Then
MsgBox "No files that match the ExtStr in this folder"
Exit Sub
End If

Get_Data _
FileNameInA:=True, _
PasteAsValues:=True, _
SourceShName:="", _
SourceShIndex:=1, _
SourceRng:="A1:G1", _
StartCell:="", _
myReturnedFiles:=myFiles

End If

End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Ladymuck" <Ladymuck@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:0BDB33E8-7DBB-4E17-B97A-287055613DA3@xxxxxxxxxxxxxxxx
I'm using Ron de Bruin's great bit of code to compile data. However, I need the MyPath value to be dynamically generated as the source folder will vary according to the user running the macro. How would I amend the code so that it does not rely on a hard coded value?

Many thanks!
.



Relevant Pages

  • Re: Visual Basic Forgets What Variables are
    ... I put all of the dim statements in front of the sub (as you ... >> HoldName will go back to the default in your code. ... >> dim AddNameLine as variant ...
    (microsoft.public.excel)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)
  • Re: find all combinations of cells that add up to certain number
    ... > Dim c As Variant ... > Dim v As Variant, x As Variant, y As Variant ... > Exit Sub ... pvt As Long ...
    (microsoft.public.excel.programming)
  • RE: Access to Outlook Public Folder
    ... If the folder is in a sub folder on the public ... Dim ol As New Outlook.Application ... 'Exit the procedure if appointment has been added to Outlook. ...
    (microsoft.public.access.modulesdaovba)
  • Re: combination of numbers
    ... Sub findsums() ... Dim c As Variant ... Dim v As Variant, x As Variant, y As Variant ... Dim j As Long, pvt As Long ...
    (microsoft.public.excel)