[英]Copying data from sheet to single row, delete then pasting row to last row on another sheet
I have been hitting my head on the desk attempting to wrack my brain in attempt to get the answer, but it seems to me that my brain just doesn't want to work. 我一直在打着桌子,试图破坏我的大脑以试图得到答案,但是在我看来,我的大脑只是不想工作。 I've gotten this far, but it seems no further...
我已经走了这么远,但似乎没有进一步...
Sub CopyValues()
Dim i As Integer
'Internal NCMR
Dim wsInt As Worksheet
Dim wsNDA As Worksheet
'Copy Ranges
Dim c As Variant
'Paste Ranges
Dim p As Range
'Setting Sheet
Set wsInt = Sheets("Internal NCMR")
Set wsNDA = Sheets("NCMR Data")
Set p = Range("B54:U54")
With wsInt
c = Array(.Range("B11"), .Range("B14"), .Range("B17"), .Range("B20"), .Range("B23"), .Range("Q11") _
, .Range("Q14"), .Range("Q17"), .Range("Q20"), .Range("R25"), .Range("V23"), .Range("V25") _
, .Range("V27"), .Range("B32"), .Range("B36"), .Range("B40"), .Range("B44"), .Range("D49") _
, .Range("L49"), .Range("V49"))
End With
For i = LBound(c) To UBound(c)
p(i + 1).Value = c(i).Value
Next
With wsNDA
Worksheets("Internal NCMR").Rows("54").Copy
Sheets("NCMR Data").Range("B" & Rows.Count).End(xlUp).Offset(1).PasteSpecial Paste:=xlPasteValues
End With
End Sub
The point of this script as explained in the topic is three fold. 如主题中所述,此脚本的要点有三点。
The third part I haven't gotten to yet, if someone could help me with that it be greatly appreciated. 第三部分我还没有讲到,如果有人可以帮助我,将不胜感激。
IS this what you are trying? 这是您要尝试的吗?
Option Explicit
Sub CopyValues()
Dim i As Integer
'Internal NCMR
Dim wsInt As Worksheet
Dim wsNDA As Worksheet
'Copy Ranges
Dim c As Variant
'Paste Ranges
Dim p As Range
'Setting Sheet
Set wsInt = Sheets("Internal NCMR")
Set wsNDA = Sheets("NCMR Data")
Set p = wsInt.Range("B54:U54")
With wsInt
c = Array(.Range("B11"), .Range("B14"), .Range("B17"), .Range("B20"), .Range("B23"), .Range("Q11") _
, .Range("Q14"), .Range("Q17"), .Range("Q20"), .Range("R25"), .Range("V23"), .Range("V25") _
, .Range("V27"), .Range("B32"), .Range("B36"), .Range("B40"), .Range("B44"), .Range("D49") _
, .Range("L49"), .Range("V49"))
End With
For i = LBound(c) To UBound(c)
p(i + 1).Value = c(i).Value
Next
With wsNDA
Dim Lastrow As Long
Lastrow = .Range("B" & Rows.Count).End(xlUp).Row + 1
wsInt.Rows("54").Copy
With .Rows(Lastrow)
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteValues
.Interior.Pattern = xlNone
End With
With .Range("A" & Lastrow)
If Lastrow = 3 Then
.Value = 1
Else
.Value = Val(wsNDA.Range("A" & Lastrow - 1).Value) + 1
End If
.NumberFormat = "0#######"
End With
End With
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.