ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Compile Error: Expected:( (https://www.excelbanter.com/excel-programming/438674-compile-error-expected.html)

Squeaky

Compile Error: Expected:(
 
I have a macro that works fine in my workbook, yet when I go into VBA and try
to run it there (using F5 or stepping into it with F8 I get the error. All of
the other macros in theis workbook work fine from VBA.

Any ideas?

Here is the macro:

Sub Line()
'
' Line Macro


'

ActiveSheet.Unprotect Password:=""

If Intersect(ActiveCell, Range("range1")) Is Nothing Then

Range("RANGE1.1").Select
Do
If IsEmpty(ActiveCell) = True Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = False
ActiveCell.Offset(-1, 1).Select
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

Else
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

End If

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("RANGE1.1").Select

End Sub



Bob Phillips[_4_]

Compile Error: Expected:(
 
Are you sure it is that macro, not another one?

HTH

Bob

"Squeaky" wrote in message
...
I have a macro that works fine in my workbook, yet when I go into VBA and
try
to run it there (using F5 or stepping into it with F8 I get the error. All
of
the other macros in theis workbook work fine from VBA.

Any ideas?

Here is the macro:

Sub Line()
'
' Line Macro


'

ActiveSheet.Unprotect Password:=""

If Intersect(ActiveCell, Range("range1")) Is Nothing Then

Range("RANGE1.1").Select
Do
If IsEmpty(ActiveCell) = True Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = False
ActiveCell.Offset(-1, 1).Select
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

Else
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

End If

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("RANGE1.1").Select

End Sub





Squeaky

Compile Error: Expected:(
 
100% sure.

I even looked at the button I have tied to the macro to make sure.

"Bob Phillips" wrote:

Are you sure it is that macro, not another one?

HTH

Bob

"Squeaky" wrote in message
...
I have a macro that works fine in my workbook, yet when I go into VBA and
try
to run it there (using F5 or stepping into it with F8 I get the error. All
of
the other macros in theis workbook work fine from VBA.

Any ideas?

Here is the macro:

Sub Line()
'
' Line Macro


'

ActiveSheet.Unprotect Password:=""

If Intersect(ActiveCell, Range("range1")) Is Nothing Then

Range("RANGE1.1").Select
Do
If IsEmpty(ActiveCell) = True Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = False
ActiveCell.Offset(-1, 1).Select
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

Else
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

End If

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("RANGE1.1").Select

End Sub




.


Dave Peterson

Compile Error: Expected:(
 
Don't use Line as the name of the sub.

Sub myLine()

is ok.

I try to stay away from using any VBA keyword as a variable, procedure, module
name.



Squeaky wrote:

I have a macro that works fine in my workbook, yet when I go into VBA and try
to run it there (using F5 or stepping into it with F8 I get the error. All of
the other macros in theis workbook work fine from VBA.

Any ideas?

Here is the macro:

Sub Line()
'
' Line Macro

'

ActiveSheet.Unprotect Password:=""

If Intersect(ActiveCell, Range("range1")) Is Nothing Then

Range("RANGE1.1").Select
Do
If IsEmpty(ActiveCell) = True Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = False
ActiveCell.Offset(-1, 1).Select
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

Else
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

End If

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("RANGE1.1").Select

End Sub


--

Dave Peterson

Squeaky

Compile Error: Expected:(
 
That was it. Perfect!

Thanks,

Squeaky

"Dave Peterson" wrote:

Don't use Line as the name of the sub.

Sub myLine()

is ok.

I try to stay away from using any VBA keyword as a variable, procedure, module
name.



Squeaky wrote:

I have a macro that works fine in my workbook, yet when I go into VBA and try
to run it there (using F5 or stepping into it with F8 I get the error. All of
the other macros in theis workbook work fine from VBA.

Any ideas?

Here is the macro:

Sub Line()
'
' Line Macro

'

ActiveSheet.Unprotect Password:=""

If Intersect(ActiveCell, Range("range1")) Is Nothing Then

Range("RANGE1.1").Select
Do
If IsEmpty(ActiveCell) = True Then
ActiveCell.Offset(1, 0).Select
End If
Loop Until IsEmpty(ActiveCell) = False
ActiveCell.Offset(-1, 1).Select
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

Else
ActualRow = Selection.Row
Cells(ActualRow + 1, 1).EntireRow.Insert
Range(Cells(ActualRow, 1), Cells(ActualRow, 33)).Copy _
Destination:=Cells(ActualRow + 1, 1)

End If

ActiveSheet.Protect Password:="", DrawingObjects:=True, Contents:=True,
Scenarios:=True
Range("RANGE1.1").Select

End Sub


--

Dave Peterson
.



All times are GMT +1. The time now is 07:24 PM.

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