Samantha27
New Member
- Joined
- Jan 30, 2024
- Messages
- 7
- Office Version
- 2016
- Platform
- Windows
Hi Good People,
Okay so I'm having a hard time fixing this code that I came across from my research.. What I wanted to achieve is this..
I have a
MasterSheet - Sheet1-Sheet2-Sheet3-NotesSheet, NoteSheet 2.
I have a macro button in the masterfile sheet that will extract the data from Sheet1-Sheet3 but exclude data from notesheet and notesheet 2.
The masterfile have the same heading of sheet1-sheet3 so I just need to extract the data daily. Up to the next available cell, but not over ride the previous data.
below is my code..
Please help me achieve this.. I can't stress this enough.. Below is my code. Thank you!!
Okay so I'm having a hard time fixing this code that I came across from my research.. What I wanted to achieve is this..
I have a
MasterSheet - Sheet1-Sheet2-Sheet3-NotesSheet, NoteSheet 2.
I have a macro button in the masterfile sheet that will extract the data from Sheet1-Sheet3 but exclude data from notesheet and notesheet 2.
The masterfile have the same heading of sheet1-sheet3 so I just need to extract the data daily. Up to the next available cell, but not over ride the previous data.
below is my code..
Please help me achieve this.. I can't stress this enough.. Below is my code. Thank you!!
VBA Code:
Sub CopyRange()
Application.ScreenUpdating = False
Dim wkbDest As Workbook
Dim wkbSource As Workbook
Set wkbDest = ThisWorkbook
Dim LastRow As Long
Const strPath As String = "c:\Users\michal\Documents\Macro\"
ChDir strPath
strExtension = Dir("*.csv*")
Do While strExtension <> ""
Set wkbSource = Workbooks.Open(strPath & strExtension)
With wkbSource
LastRow = .Sheets(1).Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
.Sheets(1).Range("A1:E" & LastRow).Copy wkbDest.Sheets(1).Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
.Close savechanges:=False
End With
strExtension = Dir
Loop
Application.ScreenUpdating = True
End Sub