Copy Cell in each Worksheet in Workbook and Paste Values into new Worksheet

esquiresurf

New Member
Joined
Mar 24, 2015
Messages
9


Hi



I would like my macro to do the following:







  1. Go through each worksheet in a workbook
  2. Find a cell value that is in all worksheets
  3. Copy the cell that is two cells to the right
  4. Paste values into a Worksheet called “Daily Net Movement”


However the error I receive is: “Object Variable or Withblock variable not set”






Here is the code:




Rich (BB code):
Rich (BB code):
Rich (BB code):
Rich (BB code):
Sub Collect_Net_Movement()



Application.ScreenUpdating = False




Dim ws As Worksheet



Dim ws1 As Worksheet



    Set ws1 =Worksheets("Daily Net Movement")


    ws1.Select


 i = 14



For Each ws In ThisWorkbook.Worksheets


 'find cell with text "Agreed Collateral Move" andcopy cell 2 cells to the right
Cells.Find("Agreed Collateral Move").Select 'Errorreceived on this line



ActiveCell.Offset(0, 2).Copy





'paste values in worksheet("Daily Net Movement")starting from Cell E14



With ws1.Range("E" & i)


    .PasteSpecialxlPasteValues
  



End With


i = i + 1



Next ws


Application.ScreenUpdating = True


End Sub






All worksheet names are different.




Any assistance in correcting this code would be greatlyappreciated.

Thank you

 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
See if this works:

Code:
Set ws1 = Worksheets("Daily Net Movement")
i = 14

For Each ws In ThisWorkbook.Worksheets
    Set c = ws.Cells.Find("Agreed Collateral Move", LookIn:=xlValues, LookAt:=xlWhole)
    If Not c Is Nothing Then
        ws1.Range("E" & i).Value = c.Offset(0, 2).Value
        i = i + 1
    End If
Next ws
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,271
Members
449,219
Latest member
daynle

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