For Each cell In Range Copy/Paste Data to another Worksheet

Felix1980

New Member
Joined
May 16, 2018
Messages
40
Hello,
I'm having a bit of trouble fixing an issue I'm having and not having much luck googling the problem. I have a loop that searches for certain things. What I'm trying to do is have the row that the search is positive for print the value from Column A of that row into another sheet. I cannot, however, figure out how to do this. Please see below for my latest try, it's having issues at "Range(nextrow).Value = cell.Offset(0, -19).Value"

Code:
Sub checkpiececount()


Dim nextrow As Long


    For Each cell In Range("T77:T580")
        If cell.Value <> 0 Then
           If cell.Offset(0, -12).Value = 0 Then
               MsgBox "No Piece Count for SKU# " & cell.Offset(0, -19).Value
                nextrow = Sheet2.Cells(Rows.Count, "A").End(xlUp).Row + 1
                Range(nextrow).Value = cell.Offset(0, -19).Value
            End If
        End If
    Next cell
Sheet2.Select
End Sub
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try:
Code:
Sub checkpiececount()
    Application.ScreenUpdating = False
    Dim cel As Range
    For Each cel In Range("T77:T580")
        If cel.Value <> 0 Then
            If cel.Offset(0, -12).Value = 0 Then
                MsgBox "No Piece Count for SKU# " & cell.Offset(0, -19).Value
                Sheet2.Cells(Sheet2.Rows.Count, "A").End(xlUp).Offset(1, 0) = cel.Offset(0, -19).Value
            End If
        End If
    Next cel
    Sheet2.Select
    Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
You are very welcome. :)
 
Upvote 0

Forum statistics

Threads
1,215,459
Messages
6,124,947
Members
449,198
Latest member
MhammadishaqKhan

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