Hello all,
I have a code which copies data from source data sheet and enters it into a different workbook . While pasting I am transposing the data . The data in the destination workbook is in a table format. The copied data when transposed is not adding to the table, I am not sure if my assumption is correct but when I remove transpose it works correctly any help on this regard will help me a lot
Attaching the code here. Thanks for your time and help in advance.
I have a code which copies data from source data sheet and enters it into a different workbook . While pasting I am transposing the data . The data in the destination workbook is in a table format. The copied data when transposed is not adding to the table, I am not sure if my assumption is correct but when I remove transpose it works correctly any help on this regard will help me a lot
Attaching the code here. Thanks for your time and help in advance.
VBA Code:
Sub repair()
Dim wbs As Workbook, wbs1 As Workbook
Dim ws As Worksheet, ws1 As Worksheet
Dim cpyrng As Range, pasterng As Range
Dim lr As Long
Set wbs = Workbooks("Repairs Enter.xlsx")
Set wbs1 = Workbooks.Open("\\DESKTOP-165T6DF\Gayathri 3\Repair Slip.xlsm")
Set ws = wbs.Sheets("Data")
Set ws1 = wbs1.Sheets("Master Sheet")
Set cpyrng = ws.Range("B1:B9")
lr = ws1.Range("A" & Rows.Count).End(xlUp).Row
Set pasterng = ws1.Range("A" & lr + 1)
If ws1.Range("A" & lr).Value = ws.Range("B1") Then
MsgBox ("Data already updated")
Else
cpyrng.Copy
pasterng.PasteSpecial xlPasteValues, xlPasteSpecialOperationNone, skipblanks:=False, Transpose:=True
wbs1.Save
wbs1.Close
End If
End Sub