what's error causes compile error sub function not defined when call macro

Alaa mg

Active Member
Joined
May 29, 2021
Messages
375
Office Version
  1. 2019
Hi
I face problem wasn't show before !!
I try calling macro from sheet change event . it gives error compile error sub function not defined when try call test
how can I fix it,please?
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Show us the code of BOTH procedures, please.
Also, what module is this other code located in?
 
Upvote 0
hi joe
in standard module
VBA Code:
Sub test()

    Dim last_row As Long
    Dim cell As Range
    last_row = ThisWorkbook.Worksheets("data").Cells(Rows.Count, 1).End(xlUp).Row
    Set cell = Range("F2:F" & last_row)
    cell.Formula = "=C2+D2-E2"
    cell.Value = cell.Value

End Sub

in sheet change event
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

'   Exit if multiple cells updated at once
    If Target.CountLarge > 1 Then Exit Sub


    If Target.Column = 3 And Target.Row > 1 Then
    If Target.Value = "" Then Target.Value = "0"
    If Not IsNumeric(Target) Then
          MsgBox "please should just enter numbers ", vbCritical
          Application.Undo
          Exit Sub
          End If
        Application.EnableEvents = False
        Call test
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0
It works just fine for me.
Are both of these procedures in the same workbook?
 
Upvote 0
yes , by the way the error occures when try save the sheet in new file by another macro .
OK, that is a very critical detail you want to be sure to mention!
What does that VBA code look like?

Are you sure that the error is with this code that you posted?
Does it give you a debug error option?
If so, and you click the word "Debug", which line of code is highighted?
 
Upvote 0
Does it give you a debug error option?
no
3.PNG

ok maybe upload the file to see closely
 
Upvote 0
yes , by the way the error occures when try save the sheet in new file by another macro .
But you say you only get the error when running some "other" macro?
Which file does this "other" macro reside in?
Which module is it in?
What does the VBA code for that module look like?
 
Upvote 0
Which file does this "other" macro reside in?
the other macro in standard module
ok I delete some macros and arranged the file again works without problem .
thanks for your time .:)
 
Upvote 0
Hi Joe ,
sorry, I came back but the error causes me headache , do me favor,please could you check my file?

here is the file
FL.xlsm
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,315
Members
452,634
Latest member
cpostell

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