以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  VBA排序  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=140197)

--  作者:zhuxinhui
--  发布时间:2019/8/31 14:31:00
--  VBA排序
VBA排序代码:Sheets("???").Range("a2:N" & K).Sort key1:=Range("A2"), order1:=xlAscending, key2:=Range("D2"), order2:=xlAscending, key3:=Range("K2"), order3:=xlDescending, Header:=xlGuess

改为FORTABLE代码:ws.Range("a2:N" & K).Sort(key1:=ws.Range("A2"),order1:=MSExcel.XlSortOrder.xlAscending,key2:=ws.Range("D2"),order2:=MSExcel.XlSortOrder.xlAscending,key3:=ws.Range("K2"),order3:=MSExcel.XlSortOrder.xlAscending) 
最后这个Header:=xlGuess怎样改
上面句改后执行得出的结果有点像是列前后排序了

--  作者:有点蓝
--  发布时间:2019/8/31 14:55:00
--  
https://docs.microsoft.com/zh-cn/dotnet/api/microsoft.office.interop.excel.xlyesnoguess?redirectedfrom=MSDN&view=excel-pia
--  作者:zhuxinhui
--  发布时间:2019/8/31 15:30:00
--  
看不懂,请指点下


--  作者:有点蓝
--  发布时间:2019/8/31 15:56:00
--  
Header:= MSExcel.XlYesNoGuess.xlGuess
--  作者:zhuxinhui
--  发布时间:2019/8/31 16:53:00
--  
ws.Range("a2:N" & K).Sort(key1:=ws.Range("A2"),order1:=MSExcel.XlSortOrder.xlAscending,key2:=ws.Range("D2"),order2:=MSExcel.XlSortOrder.xlAscending,key3:=ws.Range("K2"),order3:=MSExcel.XlSortOrder.xlAscending,Header:=MSExcel.XlYesNoGuess.xlGuess)得出的结果不是对列中的行进行排序,而是对列进行了调换位,不知是什么回事


--  作者:zhuxinhui
--  发布时间:2019/8/31 17:12:00
--  
关于使用FORTABLE操作VBA相关知识点,就是将VBA转化成FORTABLE相关的知识点,有什么书介绍下
--  作者:有点蓝
--  发布时间:2019/8/31 17:15:00
--  
试试,自行把换行去掉

ws.Range("a2:N" & K).Sort(ws.Range("A2"),
System.Reflection.Missing.Value,
System.Reflection.Missing.Value, 
MSExcel.XlSortOrder.xlAscending,
System.Reflection.Missing.Value,
MSExcel.XlSortOrder.xlAscending,
Excel.XlYesNoGuess.xlNo, 
System.Reflection.Missing.Value, 
System.Reflection.Missing.Value,
MSExcel.XlSortOrientation.xlSortRows,
MSExcel.XlSortMethod.xlStroke,
MSExcel.XlSortDataOption.xlSortNormal,
MSExcel.XlSortDataOption.xlSortNormal,
MSExcel.XlSortDataOption.xlSortNormal)