简体   繁体   English

VBA Excel中的错误400

[英]error 400 in vba-excel

I'm fairly new to vba and i don't understand why i'm getting error 400. 我是vba的新手,我不明白为什么会收到错误400。

I'm having this list. 我有这个清单。 When i push the button, this list has to be deleted, you have to select a file and then the new list will be copied from this file to the list. 当我按下按钮时,必须删除此列表,您必须选择一个文件,然后新列表将从该文件复制到列表中。 The list is always the same amount of columns (AJ), variable in length (rows) so in column K i can put a formula to test some data in the list according to data on another sheet. 该列表始​​终是相同数量的列(AJ),长度(行)是可变的,因此,在K列中,我可以根据另一个工作表上的数据测试公式以测试列表中的某些数据。

The problem is with the vba-line 问题在于vba-line

.Sheets("Blad1").UsedRange.Copy LijstBP.Sheets("Blad1").Range("A1")

To test my code, I used a list on sheet "Blad2". 为了测试我的代码,我在工作表“ Blad2”上使用了一个列表。 My code works perfect with all lists i'm trying to copy. 我的代码可以与我要复制的所有列表完美配合。 (ofcourse i had to change the code to "Blad2") Now, the new lists are on sheet "Blad1". (当然,我不得不将代码更改为“ Blad2”。)现在,新列表位于工作表“ Blad1”上。 I only changed "Blad2" into "Blad1" and the error occurs... 我只将“ Blad2”更改为“ Blad1”,并且发生了错误...

Someone can spread a light on this? 有人可以对此发表看法吗? Thanks. 谢谢。 My entire code is: 我的整个代码是:

Sub ImporteerData()
Dim LijstBP As Workbook
Dim Bron As Workbook
Set LijstBP = ActiveWorkbook

Call WisHuidigeLijst

With Application.FileDialog(msoFileDialogOpen)
    .Filters.Clear
    .Filters.Add "Excel 2007-13", "*.xlsx; *.xlsm; *.xlsa"
    .AllowMultiSelect = False
    .Show
    If .SelectedItems.Count > 0 Then
        Workbooks.Open .SelectedItems(1)
        With ActiveWorkbook
            .Sheets("Blad1").UsedRange.Copy LijstBP.Sheets("Blad1").Range("A1")
            .Close False
        End With
    End If
End With
'Formule kopiëren
Set LijstBP = ActiveWorkbook
Range("K3").FillDown
End Sub

Private Sub WisHuidigeLijst()
Dim laatsteRij As Integer

laatsteRij = Cells(3, "A").End(xlDown).Row
ActiveSheet.Range("A1").Select

Range("A1:J" & laatsteRij).Value = ""
End Sub

I just solved the problem: My collegue, who makes the lists that i need to import, did something wrong: he created a list from columns AI instead of AJ. 我刚刚解决了这个问题:我的同事创建了我需要导入的列表,但做错了什么:他从AI列而不是AJ列创建了一个列表。 By creating a new list from AJ, the whole thing works. 通过从AJ创建新列表,整个过程就可以了。 My apologies for bothering with such stupidity :-) Last week, i didn't notice this. 我为如此愚蠢而感到抱歉:-)上周,我没有注意到这一点。 Thanks to all for trying to help me. 感谢所有尝试帮助我的人。

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

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