VBA error 40036 When checking value of cell

Octonet

New Member
Joined
Sep 5, 2020
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
Sub New()
If Sheets("Mo D").Range("O1").Value = 1 Then
Sheets("Import").Select
Application.ScreenUpdating = False
Sheets("Import").Range("D3:D5").Copy
Sheets("Import").Range("E3:E5").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Import").Range("D10:D19").Copy
Sheets("Import").Range("E10:E19").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Import").Range("D24:D41").Copy
Sheets("Import").Range("E24:E41").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Import").Range("D44:D61").Copy
Sheets("Import").Range("E44:E61").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End If
End Sub

I always get this error in the first line (If Sheets ..................).
The value of O1 is the number of the week.
In the complete script, the "End If" is coming after 52 x Else If.
I used this method several times before without any problem.
 

Some videos you may like

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Peter_SSs

MrExcel MVP, Moderator
Joined
May 28, 2005
Messages
48,400
Office Version
  1. 365
Platform
  1. Windows
First thing I would do is try renaming the procedure since 'New' is a word used within vba itself.
 

Octonet

New Member
Joined
Sep 5, 2020
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
Thanks for the reply Peter.
I tried renaming; but without succes :(
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
In the VB Editor select Debug > Compile & fix any errors it comes up in.
That might help.
 
Solution

Octonet

New Member
Joined
Sep 5, 2020
Messages
21
Office Version
  1. 2019
Platform
  1. Windows
Thanks Fluff; that has put me into the right direction. There was an error in another script.
It is solved now.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
55,794
Office Version
  1. 365
Platform
  1. Windows
Glad we could help & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,128,119
Messages
5,628,799
Members
416,340
Latest member
PJB1102

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
Top