Debugging VBA built on Excel2013 not working on v2016

Nayaralist

New Member
Joined
Oct 26, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hi!
I am New here :)
We updated recently to excel 2016 and when trying to run the onld VBAs we get errors in the code we did not get before the update... maybe there are changes we re not aware...

Also, the code was developed by and external and have no clue what can be going wrong....



We have the following code:



VBA Code:
Sub MainReadOpenedFile()

Application.ScreenUpdating = False

GFILENAME = InputBox("Please type your File Name with .xlsx", , "File Name.xlsx")

GPMLibraryMasterSheet = "PM Library (Master)"

If Not Right(GFILENAME, 5) = ".xlsx" Then

GoTo FileErrorHandler

ElseIf GFILENAME = " " Then

GoTo FileErrorHandler

Else:

Application.ScreenUpdating = False

OpenFileCheck = False

Call ReadDataFromFile

End If

Exit Sub

FileErrorHandler:

MsgBox "Not an Excel file, please try again"

End Sub



Sub ReadDataFromFile()

Application.ScreenUpdating = False

Dim PMRoutineInfo(4) As Variant

Dim TLCInfo(4) As Variant

Dim TLCActivityX() As Variant

Dim PMCActivity() As Variant

Dim Compliance As String

Dim PMRoutineSchedule(10) As Variant

Dim TableInfo() As Variant

Dim TLCNo As String

Dim ErrorMessage As String

FirstRow = 3 'First row of file. LastRow if meets "End"

PMStartRow = FirstRow

Do While Not Range("D" & PMStartRow).Value = "End" 'to stop the loop (in column D)

''''

Application.ScreenUpdating = False

Workbooks(OpenFile.GFILENAME).Activate

Worksheets(OpenFile.GPMLibraryMasterSheet).Activate

etc...



But I have been getting errors on these last 2 lines: Run time error '9' "Subscript out of range"



I am moving teams and must handover this soon, so was trying to test it to show it to my successor, but I cannot figure out what can be wrong here since I did not do the code, only guided the development of it, please your help!

Thank youu!!

Also asked here Debugging VBA built on Excel2013 not working on v2016
here Debugging VBA built on Excel2013 not working on v2016 - OzGrid Free Excel/VBA Help Forum
and here Debugging VBA built on Excel2013 not working on v2016
 
Last edited by a moderator:

Some videos you may like

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

offthelip

Well-known Member
Joined
Dec 23, 2017
Messages
1,719
Office Version
  1. 2010
Platform
  1. Windows
try changing the two lines to:
VBA Code:
Workbooks.Open GFILENAME

Worksheets(GPMLibraryMasterSheet).Activate
 

Nayaralist

New Member
Joined
Oct 26, 2020
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
I tried this but it did not work.. However, I got the suggestion that this might be due to the files being opened in different instances of excel and this actually solved the issue!
Thank you!
 

Watch MrExcel Video

Forum statistics

Threads
1,126,944
Messages
5,621,753
Members
415,854
Latest member
Tutu123

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
Top