Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
右移时Excel将取消单元格排序_Excel_Vba - Fatal编程技术网

右移时Excel将取消单元格排序

右移时Excel将取消单元格排序,excel,vba,Excel,Vba,当我使用以下代码时,为什么单元格会取消排序 Dim numOfRow As Integer numOfRows = Worksheets("result").Cells(Rows.Count, "s").End(xlUp).Row Range("S10:V" & CStr(numOfRows)).Select Application.CutCopyMode = False Selection.Insert shift:=xlToRight 换班前单元格内容:236259 右移后:32

当我使用以下代码时,为什么单元格会取消排序

Dim numOfRow As Integer
numOfRows = Worksheets("result").Cells(Rows.Count, "s").End(xlUp).Row

Range("S10:V" & CStr(numOfRows)).Select
Application.CutCopyMode = False
Selection.Insert shift:=xlToRight
换班前单元格内容:236259 右移后:324359
(有3400个单元格,所以它们会随机混合,但为什么?在第242行之后,它们被正确地移动了,单元格内容也应该如此。)

哦,我的上帝。我太笨了。我找到了解决办法。我忽略了以下代码:


行(“21:241”)。选择选择。排序键1:=Range(“H21”)、Order1:=xlAscending、\uheader:=xlGuess、OrderCustom:=1、MatchCase:=False、Orientation:=xltoptobttom、\udataoption1:=xlSortNormal Range(“H21”)。选择

我有一个带数字的列。然后我想将它们向右移动,并在移动的列的列位置插入一列。是的,有更多的代码,但我认为它不是真正相关的。我一步一步地调试,发现在移位前和移位后,数字在列中的顺序是正确的,它们是随机混合的。(谢谢你的帮助。)哦,我的上帝。我太笨了。我找到了解决办法。我浏览了以下代码:
行(“21:241”)。选择选择选项。排序键1:=Range(“H21”)、顺序1:=xlAscending、Header:=xlGuess、OrderCustom:=1、MatchCase:=False、Orientation:=xlTopToBottom、uDataOption1:=xlSortNormal Range(“H21”)。选择
如果您发布答案并将其标记为已接受,效果会更好。