Always I am indebted.
This time, I asked a question because the Excel macro causes an error.
Macros that work normally on my PC stop with an error on the way on other PCs.
It stops with an error at the part of the instruction that sorts in numerical order.
-Runtime error is "438"
・ The error is the code below
ActiveWorkbook.Worksheets ("Payment Request List"). Sort.SortFields.Add2 Key: = Range (_ "A2: A1048576"), SortOn: = xlSortOnValues, Order: = xlAscending, DataOption: = _ xlSortNormal
・ Both Excel versions are "2016"
-Both macro security is "execute all macros"
・ PC is "Windows 10"
・ Introduce my Excel file to another PC as it is
MsgBox "Before Sorting" 'Sort in ascending number order Windows ("Payment application list.xlsm"). Activate Columns ("A: N"). Select ActiveWorkbook.Worksheets ("Payment Request List"). Sort.SortFields.Clear ** ActiveWorkbook.Worksheets ("Payment Request List"). Sort.SortFields.Add2 Key: = Range (_ "A2: A1048576"), SortOn: = xlSortOnValues, Order: = xlAscending, DataOption: = _ xlSortNormal ** With ActiveWorkbook.Worksheets ("Payment Request List"). Sort .SetRange Range ("A1: N1048237") .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With
If there is any other necessary information, I will describe it.
I look forward to working with you.
Answer # 1
Why not try Add instead of Add2?
It seems that Add2 cannot be used depending on how Windows Update is applied.
Answer # 2
The Add2 method seems to have been enhanced in 2016, and there may be environments where it cannot be used in 2016.
How about replacing Add2 with Add?
- excel vba that does not overwrite and save only when an error occurs
- excel - i get a python3 filenotfound error
- error when reading excel in python
- vba - about excel macros
- excel vba find gives an error that the index is out of scope
- macros created in excel on vba mac cannot be executed normally on windows
- about excel vba out of memory error
- excel vba causes automation error when duplicating sheet
- vba - i'm having trouble with excel macros i want to copy the contents of a sheet and paste it as it is on a new sheet
- vba - how to get an excel workbook that opens automatically after downloading automatically
- extract and copy vba data
- vba - i want to transfer to a cell that meets two conditions
- to find values from a range with excel vba
- vba - i want to copy the last line and paste it to the last line +1
- vba sheet 1 a7, c7, sheet 2 a2 "2020" 03 "01" numerical value is added and displayed in the cell as "20
- vba error occurs after the second time
- cannot read file with vba adodbstream
- vba - draw a ruled line only for the table below
- vba - i want to create a macro that does not post data under certain conditions, but the conditions do not work