Hi All,
I can't seem get my code to work where on the Input tab I want cell D4 to copy and paste just values and numbers into the B column on the KM Tab. There is a formula in D4 which is (=MAX(Detailis!B4:B51)+1) which results in 'D005' and will increase when new items get added to the list.
The issue I'm having is I need these ref numbers 'D00X' to also be copied into the KM tab but pasted as the values and number format as there are also 'KM0X' refs on the KM tab.
I keep getting errors for the code from 'pastespecial method of range class failed' to 'unable to get the pastespecial property of the range class' but can't get the result on the B column on the KM tab to be 'D005'
can anyone help or advise what I'm doing wrong?
Sub CopySource()
Dim wsData As Worksheet
Dim iRow As Long
Set wsData = Sheets("Input")
With Worksheets("Details")
iRow = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Range("B" & iRow).Resize(, 21).Value = Application.Transpose(wsData.Range("D4:D25").Value)
End With
With Worksheets("KM")
iRow = .Cells(Rows.Count, 2).End(xlUp).Row + 1
wsData.Range("D4").Copy
.Range("B" & iRow).Resize(, 1).PasteSpecial Paste:=xlPasteValuesAndNumbersFormats
.Range("C" & iRow).Resize(, 20).Value = Application.Transpose(wsData.Range("D5:D25").Value)
End With
End Sub
I can't seem get my code to work where on the Input tab I want cell D4 to copy and paste just values and numbers into the B column on the KM Tab. There is a formula in D4 which is (=MAX(Detailis!B4:B51)+1) which results in 'D005' and will increase when new items get added to the list.
The issue I'm having is I need these ref numbers 'D00X' to also be copied into the KM tab but pasted as the values and number format as there are also 'KM0X' refs on the KM tab.
I keep getting errors for the code from 'pastespecial method of range class failed' to 'unable to get the pastespecial property of the range class' but can't get the result on the B column on the KM tab to be 'D005'
can anyone help or advise what I'm doing wrong?
Sub CopySource()
Dim wsData As Worksheet
Dim iRow As Long
Set wsData = Sheets("Input")
With Worksheets("Details")
iRow = .Cells(Rows.Count, 2).End(xlUp).Row + 1
.Range("B" & iRow).Resize(, 21).Value = Application.Transpose(wsData.Range("D4:D25").Value)
End With
With Worksheets("KM")
iRow = .Cells(Rows.Count, 2).End(xlUp).Row + 1
wsData.Range("D4").Copy
.Range("B" & iRow).Resize(, 1).PasteSpecial Paste:=xlPasteValuesAndNumbersFormats
.Range("C" & iRow).Resize(, 20).Value = Application.Transpose(wsData.Range("D5:D25").Value)
End With
End Sub