• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Code does Work for MS 2016 but not 2019

Hi i have below code i am using this on excel 2016 it is working fine but when run this code on 2019 it does not work.

Code:
Sub Exce20192016()
Dim xFd As FileDialog
Dim xFdItem As Variant
Dim xFileName As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xFd = Application.FileDialog(msoFileDialogFolderPicker)
If xFd.Show = -1 Then
 xFdItem = xFd.SelectedItems(1) & Application.PathSeparator
 xFileName = Dir(xFdItem & "*.csv*")
 
 Dim xCount As Integer
 xCount = Application.InputBox("Number of Rows", "Kutools for Excel", , , , , , 1)
 Do While xFileName <> ""
 With Workbooks.Open(xFdItem & xFileName)
 Dim I As Long
LableNumber:
If xCount < 1 Then
GoTo LableNumber
End If
For I = Range("A" & Rows.CountLarge).End(xlUp).Row To 2 Step -1
Rows(I).Copy
Rows(I).Resize(xCount).Insert
 Next
 Application.CutCopyMode = False
 End With
 xFileName = Dir
 Loop
End If
Dim wb As Workbook
 For Each wb In Workbooks
 wb.Close SaveChanges:=True
 Next wb
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 
Be patient, we are volunteers and it hasn't even been a day since you posted your question.

As for your question... There's nothing that changed between Excel 2016 to 2019 that would break the code.

Likely cause is your environment (OS, folder permission etc) or some other factor such as add-in interfering with the code.
 
Like I stated. If the code worked in Excel 2016, there's nothing that would prevent it from running on Excel 2019. There must be something else that's impeding code execution.
 
Back
Top