Hi,
Can some excel genius help me out?
I have multiple worksheets, lets say Sheet1 to Sheet 10
Depending on the Value in Column A, the whole row should be moved to the first empty row in the respective sheet. E.g:
Value A --> Sheet 1
Value B --> Sheet 2
Value C --> Sheet 3
…..
However, value A, B ,C can all appear in Sheet 1 and then B and C should be moved accordingly. The value can change in Column A over time except and should be moved again. The last sheet would be the Archive and no changes will be made there anymore.
In the below Macro, I have only managed to move from Sheet1 to Sheet2 fo the condition ValueA.
You would really help me out a lot guys.
Sub Repair()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Sheet1").UsedRange.Rows.Count
J = Worksheets("Sheet2").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Sheet1").Range("A2:A" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "ValueA" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "ValueA" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub
Can some excel genius help me out?
I have multiple worksheets, lets say Sheet1 to Sheet 10
Depending on the Value in Column A, the whole row should be moved to the first empty row in the respective sheet. E.g:
Value A --> Sheet 1
Value B --> Sheet 2
Value C --> Sheet 3
…..
However, value A, B ,C can all appear in Sheet 1 and then B and C should be moved accordingly. The value can change in Column A over time except and should be moved again. The last sheet would be the Archive and no changes will be made there anymore.
In the below Macro, I have only managed to move from Sheet1 to Sheet2 fo the condition ValueA.
You would really help me out a lot guys.
Sub Repair()
Dim xRg As Range
Dim xCell As Range
Dim I As Long
Dim J As Long
Dim K As Long
I = Worksheets("Sheet1").UsedRange.Rows.Count
J = Worksheets("Sheet2").UsedRange.Rows.Count
If J = 1 Then
If Application.WorksheetFunction.CountA(Worksheets("Sheet2").UsedRange) = 0 Then J = 0
End If
Set xRg = Worksheets("Sheet1").Range("A2:A" & I)
On Error Resume Next
Application.ScreenUpdating = False
For K = 1 To xRg.Count
If CStr(xRg(K).Value) = "ValueA" Then
xRg(K).EntireRow.Copy Destination:=Worksheets("Sheet2").Range("A" & J + 1)
xRg(K).EntireRow.Delete
If CStr(xRg(K).Value) = "ValueA" Then
K = K - 1
End If
J = J + 1
End If
Next
Application.ScreenUpdating = True
End Sub