ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   compile error? (https://www.excelbanter.com/excel-programming/365066-compile-error.html)

leonidas[_18_]

compile error?
 

Hi,

I have the following macro in VBE, but by running it an error occurs.
It is a compile error and the problem is the range with named ranges in
it.
Does someone have a solution? Thanks in advance!

Sub RijInvoegen()

If Intersect(ActiveCell, Range("ToegestaneRijenOnderbouw",
"ToegestaneRijenSkelet", _
"ToegestaneRijenGevelDakPrefab", "ToegestaneRijenDiversen")) Is
Nothing Then
MsgBox "U kunt hier geen rij invoegen"
Else
Call InvoegenRij
End If

End Sub
------------------------------------------------------------------------
Private Sub InvoegenRij()

Application.ScreenUpdating = False
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow

Selection.Offset(1).EntireRow.SpecialCells(xlConst ants).ClearContents

End Sub


--
leonidas
------------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=554506


Norman Jones

compile error?
 
Hi Leonidas,

Try:

'=============
Public Sub RijInvoegen()
If Intersect(ActiveCell, _
Union(Range("ToegestaneRijenOnderbouw"), _
Range("ToegestaneRijenSkelet"), _
Range("ToegestaneRijenGevelDakPrefab"), _
Range("ToegestaneRijenDiversen"))) Is Nothing Then
MsgBox "U kunt hier geen rij invoegen"
Else
Call InvoegenRij
End If
End Sub
'<<=============


---
Regards,
Norman



"leonidas" wrote in
message ...

Hi,

I have the following macro in VBE, but by running it an error occurs.
It is a compile error and the problem is the range with named ranges in
it.
Does someone have a solution? Thanks in advance!

Sub RijInvoegen()

If Intersect(ActiveCell, Range("ToegestaneRijenOnderbouw",
"ToegestaneRijenSkelet", _
"ToegestaneRijenGevelDakPrefab", "ToegestaneRijenDiversen")) Is
Nothing Then
MsgBox "U kunt hier geen rij invoegen"
Else
Call InvoegenRij
End If

End Sub
------------------------------------------------------------------------
Private Sub InvoegenRij()

Application.ScreenUpdating = False
ActiveCell.Offset(1, 0).EntireRow.Insert
ActiveCell.EntireRow.Copy ActiveCell.Offset(1, 0).EntireRow

Selection.Offset(1).EntireRow.SpecialCells(xlConst ants).ClearContents

End Sub


--
leonidas
------------------------------------------------------------------------
leonidas's Profile:
http://www.excelforum.com/member.php...o&userid=35375
View this thread: http://www.excelforum.com/showthread...hreadid=554506




leonidas[_19_]

compile error?
 

Hi Norman,

Thanks for your help! It works perfect now

--
leonida
-----------------------------------------------------------------------
leonidas's Profile: http://www.excelforum.com/member.php...fo&userid=3537
View this thread: http://www.excelforum.com/showthread.php?threadid=55450



All times are GMT +1. The time now is 06:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com