简体   繁体   English

VBA Macro无法在法语Excel上运行

[英]VBA Macro not working on French excel

I have built a macro for my French counterparts, and it doesn't seem to want to work. 我为我的法国同行建立了一个宏,它似乎不想工作。 I understand there are some functions that need to be changed, eg LEN becomes NBCAR (according to the website I found). 我了解有些功能需要更改,例如LEN变为NBCAR(根据我发现的网站)。 After doing this it errors saying "Sub or function not defined" (in French) whilst highlighting NBCAR. 完成此操作后,在突出显示NBCAR时会出现错误提示“未定义子或函数”(法语)。 In my version of the macro, LEN is not defined so its slightly frustrating. 在我的宏版本中,未定义LEN,因此有点令人沮丧。 Is there a quick fix, perhaps a way to tell VBA to read the code in English? 是否有快速解决方案,也许是一种方法,可以告诉VBA用英语阅读代码?

Any help would be greatly appreciated. 任何帮助将不胜感激。

Thank You 谢谢

Code from my English Macro: 来自我的英语宏的代码:

Application.ScreenUpdating = False
Dim sh1 As Worksheet, N As Long
Dim st As String
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Dim sPath As String
Set sh1 = Sheets("VTR - MASTER")
Dim R As Integer
Dim Z As Range
Dim VTR As String
Dim W As Integer
R = 1
W = 1
VTR = Sheets("VTR - INFO").Range("J1").Value

MsgBox "Select Destination To Save ORT CSV", vbInformation, "Select Destination"
    With Application.FileDialog(msoFileDialogFolderPicker)
    .AllowMultiSelect = False
    .Show

    If .SelectedItems.Count > 0 Then
        sPath = .SelectedItems(1)

' Filter Merchant ID

MERCHID = sh1.Cells(Rows.Count, "A").End(xlUp).Row

For i = 2 To MERCHID
    v = sh1.Cells(i, 1).Value
    If v <> "" Then
        st = st & v & ","
    End If
Next i
st = Mid(st, 1, Len(st) - 1)
Arr1 = Split(st, ",")

Sheets("VTR - DATA").Select
Sheets("VTR - DATA").AutoFilterMode = False
With Sheets("VTR - DATA").Range("A:Q")
    .AutoFilter Field:=2, Criteria1:=Arr1, Operator:=xlFilterValues
    .AutoFilter Field:=1, Criteria1:= _
    "<>SOR"
    End With


Set rng1 = Application.Intersect(ActiveSheet.UsedRange, Range("F:G,K:L"))
rng1.Offset(1, 0).SpecialCells(xlCellTypeVisible).Copy
Sheets("CSV").Cells(Rows.Count, "A").End(xlUp).Offset(1).PasteSpecial xlPasteValues
Application.CutCopyMode = False

Sheets("VTR - DATA").AutoFilterMode = False
Range("A1").Select

There is missing End If for: 存在缺失的End If为:

If .SelectedItems.Count > 0

And End With for: End With

With Application.FileDialog(msoFileDialogFolderPicker)

After that it compiles OK. 之后,它将编译确定。 (Of course it does not run, because I do not have sheet with name "VTR - MASTER" and etc.) (当然它不会运行,因为我没有名称为“ VTR-MASTER”等的工作表。)

If VBA editor shows an error by functions like LEN please check missing references in menu Tools - References. 如果VBA编辑器通过LEN类的功能显示错误,请检查菜单“工具-参考”中缺少的参考。 Sometimes missing references confuses VBA that it shows an error even by internal functions. 有时缺少引用会使VBA混淆,即使通过内部函数它也会显示错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM