Copy certain values to other sheet based on cell value

Heimdal

New Member
Joined
Nov 18, 2015
Messages
15
Hej MrExcel

What I am searching for might seem easy for some, but my VBA skills are sadly very limited.

Essentially I am look for a code that Looks at all values in X column. If a value is greater than 1, it copies other cells to Crafting Sheet.

So for example as you can see, X12 has a value greater than 1, I want the code to copy A12, X12 and Y12 to the Sheet "crafting" to Q6, R6 and S6.

If more values are greater then the code simply goes to the next line and paste is, and so on. Formatting should follow.
When the VBA code runs anew it should clear out old data from the Sheet "crafting" to Q6, R6 and S6.

Please see screenhots below.

I have cried the following code, but I cannot get anywhere near where I want to be sadly.

VBA Code:
Sub Copy()
    Dim xRg As Range
    Dim xCell As Range
    Dim I As Long
    Dim J As Long
    Dim K As Long
    I = Worksheets("Item DATA").UsedRange.Rows.Count
    J = Worksheets("Crafting").UsedRange.Rows.Count
    If J = 1 Then
       If Application.WorksheetFunction.CountA(Worksheets("Crafting").UsedRange) = 0 Then J = 0
    End If
    Set xRg = Worksheets("Crafting").Range("C1:C" & I)
    On Error Resume Next
    Application.ScreenUpdating = False
    For K = 1 To xRg.Count
        If CStr(xRg(K).Value) = "Done" Then
            xRg(K).EntireRow.Copy Destination:=Worksheets("Crafting").Range("A" & J + 1)
            xRg(K).EntireRow.Delete
            If CStr(xRg(K).Value) = "Done" Then
                K = K - 1
            End If
            J = J + 1
        End If
    Next
    Application.ScreenUpdating = True
End Sub

Capture.PNG


Capture2.PNG
 

Some videos you may like

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop

Watch MrExcel Video

Forum statistics

Threads
1,112,802
Messages
5,542,585
Members
410,561
Latest member
Sasha Lawrence
Top