Hi,
i have a workbook as a masterfile and want to open another workbook to copy the data and paste it to my masterfile.
here's the problem if my data only have the first row and the second row onwards is empty data. my current VBA code will copy the empty data and will cause the error when i paste the empty data into my masterfile.
what is the VBA code to copy only the first row if only the first row of data available? then copy the entire row if the data is more than 1 row. the data is only available from column A to column T.
My current code is below. Hope can assist to correct my code below. Also please check my Application.ScreenUpdating's code is it in the correct sequence?
Sub CopyStatement()
'
' Macro2 Macro
'
'
Application.ScreenUpdating = False
Range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Range("A1").Select
Dim fPath As String, fName As String
fPath = ActiveSheet.Range("R1").Text
If Right(fPath, 1) <> "\" Then fPath = fPath + "\"
fName = ActiveSheet.Range("T1").Text
Dim wb As Workbook
Set wb = Workbooks.Open(Filename:=fPath + fName, ReadOnly:=False)
ActiveCell.Range("A1:T1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("NCF_OCBC daily statement (Master File).xlsm").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
Application.CutCopyMode = False
ActiveWorkbook.Save
Windows(Range("T1").Text).Activate
ActiveWindow.Close
Application.ScreenUpdating = False
End Sub
Bookmarks