Hi Everyone....good to be part of this great coding world. I am a beginer and learning from this pool of genius peoples.
I have one Master File (attached) where I already have one code to pull worksheets from one folder and select the desired range to copy and paste in the Master File.
Now I want to match the Year & Month of Input file and paste the data exactly below the same year in Master file.
I am not able to paste the data by matching the Month and year of Input File and Master file.....
Your help and guidence is highly appreciated
below is the current code
I have one Master File (attached) where I already have one code to pull worksheets from one folder and select the desired range to copy and paste in the Master File.
Now I want to match the Year & Month of Input file and paste the data exactly below the same year in Master file.
I am not able to paste the data by matching the Month and year of Input File and Master file.....
Your help and guidence is highly appreciated
below is the current code
Code:
Sub Button1_Click()
'Last cell in column
Dim sd As Worksheet, rd As Range, ws As Worksheet
Set sd = ThisWorkbook.Sheets("Master")
Set rd = sd.Range("B5:AE25")
Dim LastCell As Range
Dim LastCellRowNumber As Long
Set ws = Worksheets("Master")
With ws
Set LastCell = .Cells(.Rows.Count, "I").End(xlUp)
LastCellRowNumber = LastCell.Row + 1
End With
Dim wb As Workbook
Dim vFile As Variant
'Set source workbook
Set wb = ActiveWorkbook
'Open the target workbook
vFile = Application.GetOpenFilename("Excel-files,*.xlsm", _
1, "Select One File To Open", , False)
'if the user didn't select a file, exit sub
If TypeName(vFile) = "Boolean" Then Exit Sub
Workbooks.Open vFile
Set wb = ActiveWorkbook
'Select cells to copy
wb.Worksheets("Input Data").Select
wb.Worksheets("Input Data").Range("B5:AE25").Select
Selection.Copy
'Go back to original workbook you want to paste into
sd.Activate
'Paste starting at the last empty row
sd.Range("I" & LastCellRowNumber).Select
Selection.PasteSpecial xlPasteValues
End Sub