Tumgik
darbopls · 7 years
Text
'Merge Worksheet(1) of multiple Workbooks into ONE Summary Worksheet 'Macro finds last row before adding subsequent contents '********************************************************************
Sub MergeWorkbooksFlexi()
Dim SummarySheet As Worksheet    Dim MyPath As String    Dim NRow As Long    Dim LastRow As Long    Dim MyFile As String    Dim WorkBk As Workbook    Dim SourceRange As Range    Dim DestRange As Range
   ' Create a new workbook and set a variable to the first sheet.    Set SummarySheet = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
   ' Modify this folder path to point to the files you want to use.    MyPath = "C:\Users\darynsit\Downloads\201704 Dashboard\"
   ' Speed up macro process    Application.EnableEvents = False    Application.ScreenUpdating = False
   ' NRow keeps track of where to insert new rows in the destination workbook.    NRow = 1
   ' Call Dir the first time, pointing it to all Excel files in the folder path.    MyFile = Dir(MyPath & "*.xl*")
   ' Loop until Dir returns an empty string.    Do While MyFile <> ""        ' Open a workbook in the folder; ignore update links        Set WorkBk = Workbooks.Open(MyPath & MyFile, False)
       ' Set the cell in column A to be the file name.        SummarySheet.Range("A" & NRow).Value = MyFile
       LastRow = WorkBk.Worksheets(1).Cells.Find(What:="*", _                 After:=WorkBk.Worksheets(1).Cells.Range("A1"), _                 SearchDirection:=xlPrevious, _                 LookIn:=xlFormulas, _                 SearchOrder:=xlByRows).Row        Set SourceRange = WorkBk.Worksheets(1).Range("A8:Z" & LastRow)
       ' Set the destination range to start at column B and        ' be the same size as the source range.        Set DestRange = SummarySheet.Range("B" & NRow)        Set DestRange = DestRange.Resize(SourceRange.Rows.Count, SourceRange.Columns.Count)
       ' Copy over the values from the source to the destination.        DestRange.Value = SourceRange.Value
       ' Increase NRow so that we know where to copy data next.        NRow = NRow + DestRange.Rows.Count
       ' Close the source workbook without saving changes.        WorkBk.Close savechanges:=False
       ' Use Dir to get the next file name.        MyFile = Dir()    Loop
   ' Call AutoFit on the destination sheet so that all    ' data is readable.    SummarySheet.Columns.AutoFit
End Sub
0 notes
darbopls · 7 years
Text
'Merge Worksheet(1) of multiple Workbooks into ONE Summary Worksheet 'Macro segments equal space for each Worksheet(1) '********************************************************************
Sub MergeWorkbooksEqual()
Dim SummarySheet As Worksheet    Dim MyPath As String    Dim NRow As Long    Dim MyFile As String    Dim WorkBk As Workbook    Dim SourceRange As Range    Dim DestRange As Range
   ' Create a new workbook and set a variable to the first sheet.    Set SummarySheet = Workbooks.Add(xlWBATWorksheet).Worksheets(1)
   ' Modify this folder path to point to the files you want to use.    MyPath = "C:\Users\darynsit\Downloads\201704 Dashboard\"
   ' Speed up macro process    Application.EnableEvents = False    Application.ScreenUpdating = False
   ' NRow keeps track of where to insert new rows in the destination workbook.    NRow = 1
   ' Call Dir the first time, pointing it to all Excel files in the folder path.    MyFile = Dir(MyPath & "*.xl*")
   ' Loop until Dir returns an empty string.    Do While MyFile <> ""        ' Open a workbook in the folder; ignore update links        Set WorkBk = Workbooks.Open(MyPath & MyFile, False)
       ' Set the cell in column A to be the file name.        SummarySheet.Range("A" & NRow).Value = MyFile
       ' Set the source range to be A9 through C9.        ' Modify this range for your workbooks.        ' It can span multiple rows.        Set SourceRange = WorkBk.Worksheets(1).Range("A1:Z30")
       ' Set the destination range to start at column B and        ' be the same size as the source range.        Set DestRange = SummarySheet.Range("B" & NRow)        Set DestRange = DestRange.Resize(SourceRange.Rows.Count, SourceRange.Columns.Count)
       ' Copy over the values from the source to the destination.        DestRange.Value = SourceRange.Value
       ' Increase NRow so that we know where to copy data next.        NRow = NRow + DestRange.Rows.Count
       ' Close the source workbook without saving changes.        WorkBk.Close savechanges:=False
       ' Use Dir to get the next file name.        MyFile = Dir()    Loop
   ' Call AutoFit on the destination sheet so that all    ' data is readable.    SummarySheet.Columns.AutoFit
End Sub
0 notes
darbopls · 7 years
Text
'Opening latest modified file
Sub OpeningLatestModifiedFile()
   Dim MyPath As String    Dim MyFile As String    Dim LatestFile As String    Dim LatestDate As Date    Dim LMD As Date
   MyPath = "C:\Users\darynsit\Downloads\"    MyFile = Dir(MyPath & "*.xlsx", vbNormal)
   If Len(MyFile) = 0 Then        MsgBox "No files were found..."        Exit Sub    End If
   Do While Len(MyFile) > 0
   LMD = FileDateTime(MyPath & MyFile)
   If LMD > LatestDate Then        LatestFile = MyFile        LatestDate = LMD    End If
   MyFile = Dir
   Loop
   Workbooks.Open MyPath & LatestFile
End Sub
0 notes
darbopls · 8 years
Photo
Tumblr media Tumblr media
0 notes
darbopls · 8 years
Text
dfsdfdfsdf
gsdrs
0 notes
darbopls · 8 years
Photo
Tumblr media
dsf
0 notes
darbopls · 8 years
Text
sdfsdfsdfsd
sfasfsfsadfasfasdf
0 notes
darbopls · 8 years
Photo
Tumblr media Tumblr media
32
0 notes
darbopls · 8 years
Text
All about the design
It’s all about the design
0 notes
darbopls · 8 years
Photo
Tumblr media
euge
0 notes
darbopls · 8 years
Photo
Tumblr media Tumblr media
<3
0 notes