View Single Post
 
Old 03-09-2017, 01:52 PM
CLoos CLoos is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Mar 2017
Posts: 4
CLoos is on a distinguished road
Unhappy set row object variable error

I have been struggling with this for days and I have tried multiple ways of getting this task done but it's always buggy. Either I get an object error with the pastespecial method or I get the object variable error with value = value, referring to the row1. If I set row1 to a range, I get the to the open.workbooks and the code stops due to a built in function. I do not know enough to fix this and I would sure appreciate some help and understanding. I just want to copy a value from an open workbook then open a closed workbook, find the value, and add an "A" six cells to the right, then close the workbook. Here's the mess I have. Please ignore the variables with "2's" I am going to delete them.

Sub Update_Log_Status2()
Dim wrkbk1 As Workbook
Dim sht1 As Worksheet
Dim row1 As Range

'Path to closed file
Const filePath1 As String = "J:\Manual PO's\Manual PO Log\Manual PO Log.xlsx"


'Stop updating the screen
Application.ScreenUpdating = False
'
'Open the workbook
Set wrkbk1 = Workbooks.Open(filePath1)

'Grab the first sheet in wrkbk
Set sht1 = wrkbk1.Sheets(1)
Set row1 = ActiveSheet.Rows



'Find value in B21 of active worksheet in colum D of closed workbook
row1 = sht1.Range("D").Find(Range("B21").Value, , xlValues, xlWhole).row
sht1.Cells(row1, 10).Value = "A"

'Close workbook & save
wrkbk1.Close True

'Set the screen to update
Application.ScreenUpdating = True

End Sub
Reply With Quote