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

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,225,156
Messages
6,183,230
Members
453,152
Latest member
ChrisMd

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