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
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,213,556
Messages
6,114,284
Members
448,562
Latest member
Flashbond

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top