有人能幫忙嗎?我有一個現有代碼,該代碼當前根據列 V 中的單元格值(上訴記錄)將整行資料從一張表(質量日志)復制到另一張表(上訴日志)。
以前它已從原始(質量日志)表中洗掉了該行,但我現在正在尋找更改代碼,以便將單元格值更改為(上訴中),然后將其移動到下一張表(上訴日志)。
請在下面查看我的代碼。我已經用 ** 表示我嘗試更改代碼
Dim xRg As Range
Dim xCell As Range
Dim i As Long
Dim j As Long
Dim K As Long
i = Worksheets("Quality Log").UsedRange.Rows.Count
j = Worksheets("Appeal Log").UsedRange.Rows.Count
If j = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Actioned").UsedRange) = 0 Then j = 0
End If
Set xRg = Worksheets("Quality Log").Range("V3:I" & i)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "Appeal Logged" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Appeal Log").Range("A" & j 1)
**xRg(K, 22).Value = "Under Appeal"**
'xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "Appeal Logged" Then
K = K - 1
End If
j = j 1
End If
Next
'Call ResizeArchiveTable
Application.ScreenUpdating = True
End Sub```
Any and all help is much appreciated.
uj5u.com熱心網友回復:
標記和復制行
Sub CopyData()
Dim wb As Workbook: Set wb = ThisWorkbook ' workbook containing this code
Dim sws As Worksheet: Set sws = wb.Worksheets("Quality Log")
Dim slRow As Long: slRow = sws.UsedRange.Rows.Count
Dim srg As Range: Set srg = sws.Range("V3:V" & slRow)
Dim dws As Worksheet: Set dws = wb.Worksheets("Appeal Log")
Dim dlRow As Long: dlRow = dws.UsedRange.Rows.Count
Dim drrg As Range: Set drrg = dws.Rows(dlRow)
Application.ScreenUpdating = False
Dim sCell As Range
Dim drCount As Long
For Each sCell In srg.Cells
If CStr(sCell.Value) = "Appeal Logged" Then
sCell.Value = "Under Appeal"
drCount = drCount 1
sCell.EntireRow.Copy drrg.Offset(drCount)
End If
Next sCell
Application.ScreenUpdating = True
MsgBox "Rows copied: " & drCount, vbInformation
End Sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/484141.html
上一篇:VBA“未定義用戶定義型別”
下一篇:停止宏移動作業表
