对于表“ TableQueue”的“过渡”列中每个非空白的单元格,我想要:
1)从表格“ TableQueue”中复制包含该单元格的整个表格行,
2)将该行粘贴到“ TableNPD”表的底部,
3)从表“ TableQueue”中删除行
除了复制/粘贴/删除之外,我已经拥有所有工作。请在下面的代码中间查看我的注释,以查看问题的出处。我是vba的新手,尽管我可以找到很多有关复制和粘贴到表底部的信息,但它们彼此之间略有不同,并且与我已经设置代码上半部分的方式有所不同。我需要一种解决方案,以对已设置的内容进行尽可能少的更改; ...我将无法理解与众不同的任何内容。
Sub Transition_from_Queue2()
Dim QueueSheet As Worksheet
Set QueueSheet = ThisWorkbook.Sheets("Project Queue")
Dim QueueTable As ListObject
Set QueueTable = QueueSheet.ListObjects("TableQueue")
Dim TransColumn As Range
Set TransColumn = QueueSheet.Range("TableQueue[Transition]")
Dim TransCell As Range
Dim TransQty As Double
For Each TransCell In TransColumn
If Not IsEmpty(TransCell.Value) Then
TransQty = TransQty + 1
End If
Next TransCell
Dim TransAnswer As Integer
If TransQty = 0 Then
MsgBox "No projects on this tab are marked for transition."
Else
If TransQty > 0 Then
TransAnswer = MsgBox(TransQty & " Project(s) will be transitioned from this tab." & vbNewLine & "Would you like to continue?", vbYesNo + vbExclamation, "ATTEMPT - Project Transition")
If TransAnswer = vbYes Then
'Add new row to NPD table
For Each TransCell In TransColumn
If InStr(1, TransCell.Value, "NPD") > 0 Then
Dim Trans_new_NPD_row As ListRow
Set Trans_new_NPD_row = ThisWorkbook.Sheets("NPD").ListObjects("TableNPD").ListRows.Add
'我在这里可以进行所有操作。我的问题在这里无所不能。
'Copy Queue, paste to NPD, and Delete from Queue
Dim TransQueueRow As Range
Set TransQueueRow = TransCell.Rows
TransQueueRow.Copy
Dim LastPasteRow As Long
Dim PasteCol As Integer
With Worksheets("NPD")
PasteCol = .Range("TableNPD").Cells(1).Column
LastPasteRow = Cells(Rows.Count, 1).End(xlUp).Row + 1
End With
ThisWorkbook.Worksheets("NPD").Cells(LastPasteRow, PasteCol).PasteSpecial xlPasteValues
答案 0 :(得分:0)
Add-AzAutoscaleSetting : Exception type: ErrorResponseException, Message: Exception of type 'Microsoft.WindowsAzure.Management.Monitoring.MonitoringServiceException' was thrown., Code: UnsupportedMetric,
Status code:BadRequest, Reason phrase: Bad Request
+ CategoryInfo : CloseError: (:) [Add-AzAutoscaleSetting], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Autoscale.AddAzureRmAutoscaleSettingCommand
是刚添加的新行的范围,因此您应该可以使用
Trans_new_NPD_row.Range
编辑:这是一个使用listobject / table方法将行从一个表移动到另一个表的工作示例
Set Trans_new_NPD_row = ThisWorkbook.Sheets("NPD").ListObjects("TableNPD").ListRows.Add
Trans_new_NPD_row.Range.Value = _
Application.Intersect(TransCell.EntireRow, QueueTable.DataBodyRange).Value
源表(目标具有相同的格式):