Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2017, 02:26 PM
NoSparks NoSparks is offline set row object variable error Windows 7 64bit set row object variable error Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

This works for me.


Code:
Sub Update_Log_Status()
    Dim wrkbk1 As Workbook
    Dim sht1 As Worksheet
    Dim row1 As Long
    Dim mywb As Workbook
    Dim sht2 As Worksheet
        
    'Path to closed file
    Const filePath1 As String = "J:\Manual POs\Manual PO Log\Manual PO Log2.xlsx"
    'Const filePath1 As String = "D:\Forum Stuff\2017\2017_03_01\CLoos\Manual PO Log2.xlsx" '<~~ test path
    
     'Stop updating the screen
    Application.ScreenUpdating = False
     
    Set mywb = ActiveWorkbook
     
     'Open the workbook
    Set wrkbk1 = Workbooks.Open(filePath1)
     
     'Grab the first sheet in wrkbk
    Set sht1 = wrkbk1.Sheets(1)
    mywb.Activate
    Set sht2 = ActiveWorkbook.Sheets("PO")
   
    'Find value in B21 of active worksheet in colum D of closed workbook
    On Error Resume Next    '<~~ incase not found
    row1 = sht1.Range("D:D").Find(sht2.Range("B21").Value, , xlValues, xlWhole).Row
    On Error GoTo 0         '<~~ turn error notification back on
    
    If row1 > 3 Then
        sht1.Cells(row1, 10).Value = "A"
    End If
    
     'Close workbook & save
    wrkbk1.Close True
     
     'Set the screen to update
    Application.ScreenUpdating = True
    
End Sub
Reply With Quote
Reply

Tags
closed workbook, excel vba, object variable error



Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Variable or With block variable not set Raza Excel Programming 8 01-15-2015 12:19 AM
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge Berryblue Mail Merge 1 11-13-2014 05:36 PM
set row object variable error Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM
set row object variable error Run-time error '91': Object variable or With block variable not set tinfanide Excel Programming 2 06-10-2012 10:17 AM
XML parsing & Object variable not set (Error 91) tinfanide Excel Programming 0 12-29-2011 08:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft