Help with Macro Error Message

Smurfit-Stone

Active Member
Joined
Dec 1, 2004
Messages
485
Hello Board,

I'm trying to get a macros to work...I keep getting the message "Compile Error - Sub or Function not defined" I don't know what this means or how to fix the problem. The macro is as follows: Can anyone tell me what to do about resolving this? Thanks

Sub copypaste()
Dim ldate As String
Dim lcolumn As Integer
Dim lfound As Boolean

On Error GoTo err_execute

'Retrieve date value to search for
*** ldate = Sheets("Kiwi Data").Range("A1").Value

*** Sheets("Production Measures").Select

*** 'Start at column B
*** lcolumn = 4
*** lfound = False

While lfound = False

***
******* 'Encountered blank cell in row 4, terminate search
If en(Cells(4, lcolumn)) = 0 Then
MsgBox "No matching date was found."
Exit Sub
ElseIf Cells(4, lcolumn) = ldate Then

*********** 'Select values to copy from "Kiwi Data" sheet
*********** Sheets("Kiwi Data").Select
*********** Range("E20:E41").Select
*********** Selection.Copy

*********** 'Paste onto "Production Measures" sheet
*********** Sheets("Production Measures").Select
*********** Cells(9, lcolumn).Select
Selection.PasteSpecial Paste:=xlValues, operation:=xlNone, skipblanks:= _
False, Transpose:=False

*********** lfound = True
MsgBox "The data has been successfully copied."
***********

******* 'Continue searching
Else
lcolumn = lcolumn + 1
End If

Wend

On Error GoTo 0

Exit Sub
err_execute:
MsgBox "An error occurred."
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Please check this row, as this raises the error I guess:
Code:
If [I][COLOR=red]en[/COLOR][/I](Cells(4, lcolumn)) = 0 Then
 
Upvote 0
Thanks guys, it got deleted while trying other things to fix this problem. I've replaced the "L", but I still get the error message. It highlights the "Sub copypaste()" section of the macro...the very beginning. I don't have a clue whats wrong. Please help
 
Upvote 0
And what is the error message this time around?
 
Upvote 0
Thats very strange since it compiles correctly here(See Peter's post).
IGNORE Is it the only macro in the module?
Or are you posting "simplified" version of the macro? IGNORE
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,541
Messages
6,179,418
Members
452,912
Latest member
alicemil

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