VBA Copying offset cells instead of entire row

Greshapa

New Member
Joined
May 23, 2022
Messages
10
Office Version
  1. 2019
Platform
  1. Windows
Hello,

I am trying to alter code that was posted by another user here, So that instead of copying an entire row to a new sheet, it copies one offset cell, to another offset cell on the corresponding sheet.

So instead of copying a row with FiftySevens to NewWSLrow, it will copy only the F column cell of that row, to the first empty cell in Column C of the new worksheet. I hope that makes sense. I'm still very new to using and altering VBA code

Thanks in advance for any help!!

VBA Code:
For Each WS In ActiveWorkbook.Worksheets 'This line starts the loop through each sheet
    If WS.Name <> NewWs.Name Then
        lrow = WS.Cells(Rows.Count, 2).End(xlUp).Row
        For i = 4 To 27 'x to x represents the row the data starts and ends in. This line starts the loop to look through the product in each sheet
            If WS.Cells(i, 2) = FiftySevens Then
                NewWsLrow = NewWs.Cells(Rows.Count, 2).End(xlUp).Row
                WS.Cells(i, 2).EntireRow.Copy NewWs.Cells(NewWsLrow + 1, 2).EntireRow 'If the loop finds the product name, then paste it to the new sheet
                NewWs.Cells(NewWsLrow + 1, 9) = WS.Name 'Add in the name of the sheet the data is coming from
            End If
        Next i
    End If
Next WS
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Actually I ended up finding a better way of going about this. I can't see a way to delete or edit my thread though
 
Upvote 0

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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