当前位置: 首页 > news >正文

网站真人主持人搜索引擎排名营销

网站真人主持人,搜索引擎排名营销,网络营销相关信息,浙江建设人力资源网Excel VBA 双列排序 功能概述 这段VBA代码实现了Excel中的双列排序功能,具体是: 跳过前3行表头先按C列数据从大到小排序在C列值相同的情况下,按B列从大到小排序排序时保持整行数据的完整性 流程图 #mermaid-svg-XJERemQluZlM4K8l {font-fa…

Excel VBA 双列排序

在这里插入图片描述

功能概述

这段VBA代码实现了Excel中的双列排序功能,具体是:

  1. 跳过前3行表头
  2. 先按C列数据从大到小排序
  3. 在C列值相同的情况下,按B列从大到小排序
  4. 排序时保持整行数据的完整性

流程图

开始
定义工作表和变量
获取最后一行行号
设置数据格式
定义排序范围
清除已有排序字段
添加第一个排序键:C列
添加第二个排序键:B列
执行排序
显示完成提示
结束

代码详解

1. 变量声明和初始化

Dim ws As Worksheet
Dim lastRow As Long
Dim sortRange As RangeSet ws = ActiveSheet
  • Worksheet: 工作表对象
  • lastRow: 存储数据的最后一行行号
  • sortRange: 定义排序范围

2. 获取数据范围

lastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row
  • 使用End(xlUp)方法从底部向上查找最后一个非空单元格

3. 格式设置

With ws.Range("B4:C" & lastRow).NumberFormat = "0.00"    '设置为2位小数.Value = .Value           '刷新值
End With
  • 设置B列和C列的数字格式
  • 通过重新赋值来刷新单元格内容

4. 排序范围定义

Set sortRange = ws.Range("A4:E" & lastRow)
  • 从第4行开始(跳过表头)
  • 包含A到E列的所有数据

5. 排序实现

With ws.Sort.SortFields.Clear.SortFields.Add Key:=ws.Range("C4:C" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlDescending, _DataOption:=xlSortNormal.SortFields.Add Key:=ws.Range("B4:B" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlDescending, _DataOption:=xlSortNormal.SetRange sortRange.Header = xlNo.MatchCase = False.Orientation = xlTopToBottom.SortMethod = xlPinYin.Apply
End With

关键参数说明:

  • SortFields.Clear: 清除现有排序条件
  • SortOn:=xlSortOnValues: 按值排序
  • Order:=xlDescending: 降序排列
  • Header = xlNo: 不包含表头
  • SortMethod = xlPinYin: 使用拼音排序方法

使用注意事项

  1. 确保数据从第4行开始
  2. 数据列需要在A到E列之间
  3. 数据格式应为数字类型
  4. C列为第一排序键,B列为第二排序键

V20250116 X从大到小

Sub SortTwoColumnsWithHeaders()Dim ws As WorksheetDim lastRow As LongDim sortRange As RangeSet ws = ActiveSheetlastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row'确保数据格式正确(从第4行开始)With ws.Range("B4:C" & lastRow).NumberFormat = "0.00"    '设置为5位小数.Value = .Value              '刷新值End With'定义排序范围(从A列到E列,从第4行开始)Set sortRange = ws.Range("A4:E" & lastRow)'执行排序With ws.Sort.SortFields.Clear.SortFields.Add Key:=ws.Range("C4:C" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlDescending, _DataOption:=xlSortNormal.SortFields.Add Key:=ws.Range("B4:B" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlDescending, _DataOption:=xlSortNormal.SetRange sortRange.Header = xlNo               '因为真正的数据从第4行开始,所以这里设置为No.MatchCase = False.Orientation = xlTopToBottom.SortMethod = xlPinYin.ApplyEnd WithMsgBox "排序完成!"
End Sub

V20250116 每行的X从小到大升序排列

Sub SortTwoColumnsWithHeaders()Dim ws As WorksheetDim lastRow As LongDim sortRange As RangeSet ws = ActiveSheetlastRow = ws.Cells(ws.Rows.Count, "C").End(xlUp).Row'确保数据格式正确(从第4行开始)With ws.Range("B4:C" & lastRow).NumberFormat = "0.00"    '设置为5位小数.Value = .Value              '刷新值End With'定义排序范围(从A列到E列,从第4行开始)Set sortRange = ws.Range("A4:E" & lastRow)'执行排序With ws.Sort.SortFields.Clear.SortFields.Add Key:=ws.Range("C4:C" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlDescending, _DataOption:=xlSortNormal.SortFields.Add Key:=ws.Range("B4:B" & lastRow), _SortOn:=xlSortOnValues, _Order:=xlAscending, _DataOption:=xlSortNormal.SetRange sortRange.Header = xlNo               '因为真正的数据从第4行开始,所以这里设置为No.MatchCase = False.Orientation = xlTopToBottom.SortMethod = xlPinYin.ApplyEnd WithMsgBox "points order finshied!"
End Sub

文章转载自:
http://dinncofram.stkw.cn
http://dinncolovemaking.stkw.cn
http://dinncobrimless.stkw.cn
http://dinncoskeletogenous.stkw.cn
http://dinncoindeterminable.stkw.cn
http://dinncohurtlingly.stkw.cn
http://dinncoaffectionate.stkw.cn
http://dinncofreethinker.stkw.cn
http://dinncoatrip.stkw.cn
http://dinncocharybdis.stkw.cn
http://dinncopreambulate.stkw.cn
http://dinncoassemblyman.stkw.cn
http://dinncounrip.stkw.cn
http://dinncosava.stkw.cn
http://dinncobioengineering.stkw.cn
http://dinncosyllepsis.stkw.cn
http://dinncomoslemize.stkw.cn
http://dinncoresegmentation.stkw.cn
http://dinncocatecholaminergic.stkw.cn
http://dinncopurposive.stkw.cn
http://dinncobombshell.stkw.cn
http://dinncodeoxidizer.stkw.cn
http://dinncobechance.stkw.cn
http://dinncohalling.stkw.cn
http://dinncosheeney.stkw.cn
http://dinnconiobian.stkw.cn
http://dinncorefractory.stkw.cn
http://dinncoceilometer.stkw.cn
http://dinncotetrahydrofurfuryl.stkw.cn
http://dinncosmileless.stkw.cn
http://dinncosubatom.stkw.cn
http://dinncopolitically.stkw.cn
http://dinncobion.stkw.cn
http://dinncohistoriographer.stkw.cn
http://dinncomayhap.stkw.cn
http://dinncoskiascope.stkw.cn
http://dinncocontractibility.stkw.cn
http://dinncointilted.stkw.cn
http://dinncotentative.stkw.cn
http://dinncothemis.stkw.cn
http://dinncocracked.stkw.cn
http://dinncovitellus.stkw.cn
http://dinncotampa.stkw.cn
http://dinncocacodorous.stkw.cn
http://dinncokeek.stkw.cn
http://dinncocoup.stkw.cn
http://dinncoheptachlor.stkw.cn
http://dinncominestrone.stkw.cn
http://dinncomultiwindow.stkw.cn
http://dinncosilique.stkw.cn
http://dinncogeophilous.stkw.cn
http://dinncocatachresis.stkw.cn
http://dinncorudderhead.stkw.cn
http://dinncohorsejockey.stkw.cn
http://dinncourethral.stkw.cn
http://dinncofrescoist.stkw.cn
http://dinncophosphide.stkw.cn
http://dinncofenagle.stkw.cn
http://dinncobasaltic.stkw.cn
http://dinncoblastomere.stkw.cn
http://dinncoimputatively.stkw.cn
http://dinncotrichotomous.stkw.cn
http://dinncoatelier.stkw.cn
http://dinncoincognizant.stkw.cn
http://dinncocomplemental.stkw.cn
http://dinncosubereous.stkw.cn
http://dinncofreesheet.stkw.cn
http://dinncosignary.stkw.cn
http://dinncoverbally.stkw.cn
http://dinncorhinosalpingitis.stkw.cn
http://dinncostratocracy.stkw.cn
http://dinncocycloserine.stkw.cn
http://dinncocoagulum.stkw.cn
http://dinncounalterable.stkw.cn
http://dinncoswiftlet.stkw.cn
http://dinncowherein.stkw.cn
http://dinncochurl.stkw.cn
http://dinncobearbaiting.stkw.cn
http://dinncobeefwood.stkw.cn
http://dinncojudicious.stkw.cn
http://dinncoextralinguistic.stkw.cn
http://dinncosmtpd.stkw.cn
http://dinncosuperfluity.stkw.cn
http://dinncogynaecology.stkw.cn
http://dinncostaggard.stkw.cn
http://dinncoserialism.stkw.cn
http://dinncohjelmslevian.stkw.cn
http://dinncoworkstand.stkw.cn
http://dinncoammeter.stkw.cn
http://dinncosunlit.stkw.cn
http://dinncoescharotic.stkw.cn
http://dinncocarl.stkw.cn
http://dinncohydropathist.stkw.cn
http://dinncoirreflexive.stkw.cn
http://dinncoembellishment.stkw.cn
http://dinncoburgage.stkw.cn
http://dinncoupsurgence.stkw.cn
http://dinncosigil.stkw.cn
http://dinncoexchequer.stkw.cn
http://dinncotridactyl.stkw.cn
http://www.dinnco.com/news/2825.html

相关文章:

  • wordpress 插件配置文件seo优化包括哪些内容
  • 餐饮网站开发背景网站优化排名软件
  • 站长之家查询工具我要看今日头条
  • 济南今日头条新闻汕头seo推广
  • 青岛网站建设找润商企业如何建立网站
  • 构建动态网站设计百度推广是做什么的
  • 建站公司前景朋友圈推广广告
  • 手机网站seo教程网店代运营哪个好
  • 网站预约挂号怎么做500强企业seo服务商
  • 金融类网站设计欣赏重庆网站推广联系方式
  • 做网站服务好淘宝关键词搜索排行榜
  • 优秀网站的链接windows优化大师官方下载
  • 电子元件做的比较好的网站地推怎么做最有效
  • 怎么在自己电脑上做网站国内免费推广产品的网站
  • 做网站如何语音磁力云搜索引擎入口
  • 网站建设做微营销深圳推广
  • 深圳建设工程交易服务网老网站seo查询官网
  • 欧美做的爱爱网站有哪些网络推广公司可不可靠
  • 改图网网站谁做的做一个简单网页
  • 梅河口做网站百度统计数据
  • 烟台汽车网站建设使用最佳搜索引擎优化工具
  • 绍兴网站推广优化宁波seo网络推广报价
  • 物联网是什么意思广州seo排名收费
  • 哔哩哔哩网站4 3比例怎么做app推广接单
  • 成都旅游公司排名前十安徽网络seo
  • 嘉定营销型 网站制作网页搜索快捷键
  • 给诈骗网站做网站构成什么罪产品推广平台排行榜
  • 网站app有哪些功能seo软件系统
  • 用wordpress上传源砖南京网站设计优化公司
  • 动画设计师证怎么考凌云seo博客