Mistake in VBA code

Diskutiere und helfe bei Mistake in VBA code im Bereich Microsoft Office im Windows Info bei einer Lösung; Hi there, the following code ought to be used to get data from an excel file to update data in my master file. Unfortunately the process just stops,... Dieses Thema im Forum "Microsoft Office" wurde erstellt von Chrischi81, 18. Januar 2021.

  1. Chrischi81
    Chrischi81 Gast

    Mistake in VBA code


    Hi there,


    the following code ought to be used to get data from an excel file to update data in my master file.

    Unfortunately the process just stops, excel closes itself and tries to repair the file and the input file is opened.

    I have no idea why it doesnt go through ... any help is greatly appreciated.


    I am using Office 365 latest version on Windows 10. Speed and space on my laptop shouldnt be the issue at all 64 GB RAM for example.


    Sub Input_Values

    Dim iwb As Workbook, iws As Worksheet, ws As Worksheet


    Application.ScreenUpdating = False


    b = GetFileThisWorkbook.Path

    If b = "" Then

    MsgBox "Select proper File", vbCritical

    Exit Sub

    Else

    file_path = b

    End If



    col_st = InputBox"Please write the first paste column number"

    col_st = CLngcol_st



    Set iwb = Workbooks.Openfile_path



    Set iws = iwb.Sheets1

    Set ws = ThisWorkbook.ActiveSheet



    ilRow = iws.Cellsiws.Rows.Count, 1.EndxlUp.Row

    ilCol = iws.Cells1, iws.Columns.Count.EndxlToLeft.Column



    lRow = ws.Cellsiws.Rows.Count, 1.EndxlUp.Row

    lCol = ws.Cellsiws.Rows.Count, 1.EndxlUp.Row





    For i = 1 To ilRow

    fo = 0

    For j = 4 To lRow

    If iws.Cellsi, 1.Value = ws.Cellsj, 1.Value Then

    iws.Rangeiws.Cellsi, 2, iws.Cellsi, ilCol.Copy ws.Cellsj, col_st

    Application.CutCopyMode = False

    fo = 1

    End If

    Next j

    If fo = 0 Then

    iws.Cellsi, 1.Copy ws.CellslRow + 1, 1

    iws.Rangeiws.Cellsi, 2, iws.Cellsi, ilCol.Copy ws.CellslRow + 1, col_st

    lRow = lRow + 1

    End If

    Next i



    iwb.Close





    Set iwb = Nothing



    End Sub





    Function GetFilestrPath As String As String



    Dim fldr As FileDialog

    Dim sItem As String

    Set fldr = Application.FileDialogmsoFileDialogFilePicker

    With fldr

    .Title = "Select a File"

    .AllowMultiSelect = False

    .InitialFileName = strPath

    .Filters.Add "Excel Files", "*.xlsx; *.xlsm; *.xls; *.xlsb", 1

    If .Show <> -1 Then GoTo NextCode

    sItem = .SelectedItems1

    End With

    NextCode:

    GetFile = sItem

    Set fldr = Nothing



    End Function



    Thank you!
     
  2. CharlesKenyon IA Win User

    Office 365 vs Office Home 2019

    Again, that logo may be just a Microsoft mistake.

    Office 365 and Office 2019 share a lot of code and cross-over happens.

    The place to check is in the Account window under File in any of the applications.
  3. Claus Busch Win User

    Zellen Kopieren mit Formelinhalt

    Hallo,

    in deinen Zellen stehen weder korrekte Formeln noch korrekter VBA-Code. Zudem gehört VBA-Code in ein Modul und nicht in ein Blatt.

    Beschreibe mal deine Daten und wie du sie auswerten willst.

    Claus
  4. Dura Cell Win User

    [VBA] Ausführung einer Funktion/eines Makros unterbinden

    Nochmal Hallo.

    Konnte mein Problem lösen. Wie sich herausgestellt hatte, lag die Ursache nicht an meinem VBA-Code oder dem VBA-Code der fremden XLSM. Es lag an einer Einstellung in Excel selbst. Waren wieder einige sehr lehrreiche Stunden. Vielen Dank.
  5. Andreas Killer Win User

    sollte man excel 4.0 makros umwandeln?

    Kann oder sollte ich den Programmcode in eine neue Excel-Makrosprache (VBA ?) umwandeln.
    Kann... kommt auf Dich an.

    Sollte... ja, wenn Du es in Zukunft weiter verwenden willst. Es ist angekündigt das VBA soweit erweitert wird das man alle Excel 4.0 Makros mit VBA nachbilden kann. Und dann wird eines Tages der alte Code nicht mehr unterstützt.

    Sprachtechnisch gesehen ist VBA um einiges einfacher als Excel 4.0, allerdings musst Du nun schon umdenken, da es nur noch Objekt-orientierte Sprachen gibt.

    Aber Vokabelprogramm... ich kann mir gar nicht vorstellen was da so umfangreich an dem Code sein soll... beschreib doch mal was Dein Code so macht.

    Andreas.
  6. Boris Wimmer Win User

    Duckerwechsel per VBA

    Hallo,

    danke für den VBA-Code. Leider habe ich es nicht genauer beschrieben, ich dachte daran, den Drucker in VBA anzugeben, damit ein Wechsel ohne Benutzerdialog erfolgen kann (dieser Code funktioniert tadellos).

    Vielleicht noch eine Idee?

    Danke.

    Gruß,

    Boris
  7. User Advert


    Hi,

    willkommen im Windows Forum!
Thema:

Mistake in VBA code - Microsoft Office

Die Seite wird geladen...

Mistake in VBA code - Similar Threads - Mistake VBA code

Forum Datum

Hilfe bei VBA-Code

Hilfe bei VBA-Code: Microsoft Excel 2019Windows 11 Hallo zusammen,ich habe folgendes Problem: Ich komme zwar mit Excel gut zurecht, kenne mich aber nicht mit VBA-Codes aus, sodass ich mithilfe von ChatGPT ich einen...
Microsoft Office 20. Januar 2025

Fehlender VBA Code in Dokument

Fehlender VBA Code in Dokument: Hallo,auf der Arbeit hat mir eine Kollegin eine Excel mit VBA Code auf einem Sharelaufwerk hochgeladen. Diese Excel brauchte ich um weiterzuarbeiten.Als ich aber die Excel öffnete war kein VBA...
Microsoft Office 16. August 2023

Error in VBA code in Excel

Error in VBA code in Excel: Good morning,I have a VBA code that was working fine and now it keeps bringing up an error message. Can someone help me here please? Thank you!
Microsoft Office 22. Juni 2023

Excel VBA-Code

Excel VBA-Code: Hallo liebe Community,ich würde gerne den Zelleninhalt aus Zelle "E8" im Tabellenblatt "Januar" als Kommentar/Notiz in das Tabellenblatt "Februar" in der Zelle "E8" übernehmen. Als nächstes soll...
Microsoft Office 27. Mai 2022

VBA Code mit Benutzerabhängigem Dateipfad

VBA Code mit Benutzerabhängigem Dateipfad: Hallo zusammen,ich muss vorab sagen, dass ich nicht wirklich viel Ahnung von Vba habe und würde euch bitten eure Antworten so einfach wie möglich zu halten.Mein Ziel ist ein Makro das Benutzer...
Microsoft Office 15. Dezember 2021

0xD0000084 Fehlercode - Mistake code

0xD0000084 Fehlercode - Mistake code: Unbekannter Fehlercode. Wir versuchen Office 365 Family zu installieren gekauft, alte Lizenz deinstalliert und erhalten bei der Installation leider immer den oben genannten Fehlercode. Wir haben...
Microsoft Office 3. Januar 2021

VBA Code Zeilenumbruch

VBA Code Zeilenumbruch: Hallo, ich sehe den Fehler im Code nicht. Nachdem ich versucht habe einen Zeilenumbruch einzuehren geht es nicht mehr... LG Co [IMG]
Microsoft Office 6. Oktober 2016
Mistake in VBA code solved
  1. Diese Seite verwendet Cookies, um Inhalte zu personalisieren, diese deiner Erfahrung anzupassen und dich nach der Registrierung angemeldet zu halten.
    Auf dieser Website werden Cookies für die Zugriffsanalyse und Anzeigenmessung verwendet.
    Wenn du dich weiterhin auf dieser Seite aufhältst, akzeptierst du unseren Einsatz von Cookies.