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
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