Run-time error 91

hsarwar14

New Member
Joined
Jun 26, 2017
Messages
2
Hi,

I am trying to run the code listed below and I get an run-time 91 error (Object variable or with block variable not set). Could someone please help me to understand why I am getting this error. Thanks.

Sub TestCode()


Dim mybook As Workbook, ElectricalCableSchedule As Workbook, mysheet As Worksheet, TCP As String, CableSchedule As Worksheet
Dim RngVisible As Range


Application.DisplayAlerts = False


Set mybook = Application.ActiveWorkbook
Set mysheet = Application.ActiveSheet


TCP = InputBox("Enter TCP")


Dim PIDsheet As Worksheet, rngTCP As Range, PIDFilename As String, Currentfilepath As String, Newfilepath As String


Set PIDsheet = mybook.Worksheets("TCP PIDs")
PIDsheet.Activate
Set rngTCP = PIDsheet.Range("$A$1:$A$100").Find(TCP)
rngTCP.Offset(0, 1).Select
PIDFilename = ActiveCell.Value
Currentfilepath = "\\nlnetappcifs01\n4wr\901_COMMISSIONING\901J_System_Turnover\TCP PIDs\All Scoped Drawings\New Scoped Drawings Unit 20 June 22" & PIDFilename
Newfilepath = ThisWorkbook.Path & "\PIDs" & PIDFilename
If Dir(Currentfilepath) <> "" Then
Else
If Dir(fullnewfilepath) <> "" Then
FileCopy Currentfilepath, Newfilepath
End If
End If


End Sub
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,223,922
Messages
6,175,386
Members
452,639
Latest member
RMH2024

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