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

官网设计效果图关键词优化排名工具

官网设计效果图,关键词优化排名工具,深圳网站制作联系电话,违规网站备案如图:对图中区域 A1:M6 横向表格,转换成区域 A1:C20 纵向表格,即 B:M 列转换成每2列一组按行写入,并删除空行。同理,反向操作就是纵向表格转换成横向表格 目录 横向转纵向实现方法1转换结果 实现方法2转换结果 纵向转横…

在这里插入图片描述
如图:对图中区域 A1:M6 横向表格,转换成区域 A1:C20 纵向表格,即 B:M 列转换成每2列一组按行写入,并删除空行。同理,反向操作就是纵向表格转换成横向表格

目录

    • 横向转纵向
      • 实现方法1
        • 转换结果
      • 实现方法2
        • 转换结果
    • 纵向转横向
      • 转换结果

横向转纵向

实现方法1

本文图1中,按“交期和交货数量”每5行2列为一组,依次按行写入,即按“交期”顺序排列

Sub 表格横向转纵向1()'分段转换,转换列之前同名不连续;不使用动态获取每行最后一列是考虑到部分选中拆分Dim num_col&, title_row&, del_empty As Boolean, rng As Range, del_rng As RangeDim first_col&, resize_r&, resize_c&, keep_rng, arr, brr, b$, r&, i&, j&
'--------------------参数填写:num_col、title_row都为数字,选中后才可运行代码num_col = 2    '需要拆分的数据每行固定的列数title_row = 1  '表头行数del_empty = True  '是否删除空行If Selection.Count = 1 Then Debug.Print "未选中列,无法运行代码": Exit SubSet rng = Intersect(ActiveSheet.UsedRange, Selection)  'intersect语句避免选择整列造成无用计算'选中区域开始列号,转换行数、列数first_col = rng.column: resize_r = rng.Rows.Count - title_row: resize_c = rng.Columns.CountIf resize_c Mod num_col <> 0 Then Debug.Print "选中列数不可平分": Exit SubWith ActiveSheetkeep_rng = .Cells(title_row + 1, 1).Resize(resize_r, first_col - 1)  '不变区域arr = .Cells(title_row + 1, first_col).Resize(resize_r, resize_c)    '转换区域r = title_row + 1  '写入行号For i = num_col + 1 To UBound(arr, 2) Step num_colr = r + resize_r: .Cells(r, 1).Resize(resize_r, first_col - 1) = keep_rngFor j = 1 To num_colbrr = Application.index(arr, , i + j - 1)  '按列拆分.Cells(r, first_col + j - 1).Resize(resize_r, 1) = brrNextNextIf del_empty Then  '删除空行For i = title_row + 1 To r + resize_rbrr = .Cells(i, first_col).Resize(1, num_col)b = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(brr)), "")If Len(b) = 0 ThenIf del_rng Is Nothing ThenSet del_rng = .Rows(i)ElseSet del_rng = Union(del_rng, .Rows(i))End IfEnd IfNextIf Not del_rng Is Nothing Then del_rng.Delete  '删除行End If.Cells(1, first_col + num_col).Resize(1, resize_c - num_col).EntireColumn.Delete  '删除选中列End With
End Sub

转换结果

本文图1(转换前不含7-20行),选中 B:M 列,运行代码得到如下图结果: D:M 列被删除
在这里插入图片描述

实现方法2

本文图1中,按“产品规格”每个产品后面6组“交期和交货数量”转换为每6行2列,依次按行写入,即按“产品”顺序排列

以下代码使用了数组行列数转换函数,调用了wraparr函数,代码详见《Excel·VBA单元格区域行列数转换函数》(如需使用代码需复制)

Sub 表格横向转纵向2()'按行转换,转换列之前同名连续;不使用动态获取每行最后一列是考虑到部分选中拆分Dim num_col&, title_row&, del_empty As Boolean, rng As Range, del_rng As RangeDim first_col&, last_row&, resize_r&, resize_c&, keep_rng, arr, brr, b$, r&, i&, j&
'--------------------参数填写:num_col、title_row都为数字,选中后才可运行代码num_col = 2    '需要拆分的数据每行固定的列数title_row = 1  '表头行数del_empty = True  '是否删除空行If Selection.Count = 1 Then Debug.Print "未选中列,无法运行代码": Exit SubSet rng = Intersect(ActiveSheet.UsedRange, Selection)  'intersect语句避免选择整列造成无用计算'选中区域开始列号、结束行号,转换行数、列数first_col = rng.column: last_row = rng.Rows.Countresize_r = rng.Rows.Count - title_row: resize_c = rng.Columns.Count: r = resize_c / num_colIf resize_c Mod num_col <> 0 Then Debug.Print "选中列数不可平分": Exit SubWith ActiveSheetFor i = last_row To title_row + 1 Step -1  '倒序循环keep_rng = .Cells(i, 1).Resize(1, first_col - 1)  '不变区域arr = .Cells(i, first_col).Resize(1, resize_c)    '转换区域arr = wraparr(arr, "row", r)  '调用函数将arr转换为r行num_col的数组.Cells(i + 1, 1).Resize(r - 1, 1).EntireRow.Insert  '插入行.Cells(i, 1).Resize(r, first_col - 1) = keep_rng.Cells(i, first_col).Resize(r, num_col) = arrNextIf del_empty Then  '删除空行j = (last_row - title_row) * r + title_row  '总行数For i = title_row + 1 To jbrr = .Cells(i, first_col).Resize(1, num_col)b = Join(WorksheetFunction.Transpose(WorksheetFunction.Transpose(brr)), "")If Len(b) = 0 ThenIf del_rng Is Nothing ThenSet del_rng = .Rows(i)ElseSet del_rng = Union(del_rng, .Rows(i))End IfEnd IfNextIf Not del_rng Is Nothing Then del_rng.Delete  '删除行End If.Cells(1, first_col + num_col).Resize(1, resize_c - num_col).EntireColumn.Delete  '删除选中列End With
End Sub

转换结果

本文图1(转换前不含7-20行),选中 B:M 列,运行代码得到如下图结果: D:M 列被删除
在这里插入图片描述

纵向转横向

使用自定义函数转换,具体说明见注释(key_col(0)为开始列号,之前的都为字典键,之后的都为待转换数据)

Function 纵向转横向(ByVal data_arr, ByVal key_col)  '按非key_col列为键横向合并数组'转换函数,arr为待转换数组(从1开始计数二维数组),key_col为列号数组(从0开始计数一维数组)'返回结果,从1开始计数二维数组;key_col(0)为开始列号,key_col(1)为结束列号,键在开始列号之前Dim dict As Object, num_col&, delimiter$, i&, j&, r&, c&, k$, max_c&, rr&, cc&If Not IsArray(data_arr) Or Not IsArray(key_col) Then Debug.Print "错误!参数都为数组": Exit FunctionSet dict = CreateObject("scripting.dictionary")num_col = key_col(1) - key_col(0) + 1: delimiter = Chr(28)  '分隔符ReDim res(1 To UBound(data_arr), 1 To UBound(data_arr) * num_col)For i = LBound(data_arr) To UBound(data_arr)k = ""For j = 1 To key_col(0) - 1k = k & delimiter & data_arr(i, j)NextIf Not dict.Exists(k) Thenr = r + 1: dict(k) = Array(r, key_col(0))For j = 1 To key_col(0) - 1res(r, j) = data_arr(i, j)NextElsec = dict(k)(1) + num_col: dict(k) = Array(dict(k)(0), c)max_c = WorksheetFunction.Max(max_c, c)  '最大列数End Ifrr = dict(k)(0): cc = dict(k)(1) - 1For j = key_col(0) To key_col(1)cc = cc + 1: res(rr, cc) = data_arr(i, j)NextNextReDim result(1 To r, 1 To max_c + num_col - 1)  '去除res数组多余部分For i = 1 To UBound(result)For j = 1 To UBound(result, 2)result(i, j) = res(i, j)NextNext纵向转横向 = result
End Function

转换结果

对“横向转纵向”无论是方法1还是方法2,生成的结果进行如下转换,生成的“纵向转横向”结果都一致,如下图

Sub 表格纵向转横向()Dim arr, brrarr = [a2:c20]: brr = 纵向转横向(arr, Array(2, 3))[d1].Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub

在这里插入图片描述
多列键也可使用自定义函数转换,更具通用性

Sub 表格纵向转横向()Dim arr, brrarr = [a2:d20]: brr = 纵向转横向(arr, Array(3, 4))[f1].Resize(UBound(brr), UBound(brr, 2)) = brr
End Sub

在这里插入图片描述
附件:《Excel·VBA表格横向、纵向相互转换(附件)》

扩展阅读:
《excelhome-多列转3列》
《excel吧-3列转多列》


文章转载自:
http://dinncosolutizer.tqpr.cn
http://dinncocannabin.tqpr.cn
http://dinncochoybalsan.tqpr.cn
http://dinncoenlister.tqpr.cn
http://dinncoprolicide.tqpr.cn
http://dinncobeset.tqpr.cn
http://dinncoaldermanry.tqpr.cn
http://dinncopereopod.tqpr.cn
http://dinncoabluent.tqpr.cn
http://dinncolander.tqpr.cn
http://dinncoapogean.tqpr.cn
http://dinncomercenary.tqpr.cn
http://dinncooutdoorsy.tqpr.cn
http://dinncounipod.tqpr.cn
http://dinncomobdom.tqpr.cn
http://dinncovivacity.tqpr.cn
http://dinncohouseleek.tqpr.cn
http://dinncoindiscretion.tqpr.cn
http://dinncourethritis.tqpr.cn
http://dinncologaniaceous.tqpr.cn
http://dinncoaquaria.tqpr.cn
http://dinncopolyuria.tqpr.cn
http://dinncocrystallitis.tqpr.cn
http://dinncohypaspist.tqpr.cn
http://dinncoralline.tqpr.cn
http://dinncobleachery.tqpr.cn
http://dinnconebraska.tqpr.cn
http://dinncoconsulship.tqpr.cn
http://dinncofireproofing.tqpr.cn
http://dinncodried.tqpr.cn
http://dinncodane.tqpr.cn
http://dinncotu.tqpr.cn
http://dinncovolte.tqpr.cn
http://dinncorecruit.tqpr.cn
http://dinncoinstitutional.tqpr.cn
http://dinncofairyism.tqpr.cn
http://dinncousefulness.tqpr.cn
http://dinncootolaryngology.tqpr.cn
http://dinncotapadera.tqpr.cn
http://dinncorhabdom.tqpr.cn
http://dinncocoarctation.tqpr.cn
http://dinncorinker.tqpr.cn
http://dinncodepend.tqpr.cn
http://dinncomormondom.tqpr.cn
http://dinncorhodochrosite.tqpr.cn
http://dinncodecumbent.tqpr.cn
http://dinncohellgrammite.tqpr.cn
http://dinncoheterodox.tqpr.cn
http://dinncoothergates.tqpr.cn
http://dinncoanxious.tqpr.cn
http://dinncoperoxidize.tqpr.cn
http://dinncodracontologist.tqpr.cn
http://dinncocryptogamic.tqpr.cn
http://dinncotrochometer.tqpr.cn
http://dinncolakelet.tqpr.cn
http://dinncohankerchief.tqpr.cn
http://dinncohousekeep.tqpr.cn
http://dinncohaunt.tqpr.cn
http://dinncoarbitrary.tqpr.cn
http://dinncocartesianism.tqpr.cn
http://dinncogametophore.tqpr.cn
http://dinncofishworm.tqpr.cn
http://dinncotarge.tqpr.cn
http://dinncounitarianism.tqpr.cn
http://dinncojampan.tqpr.cn
http://dinncotelegu.tqpr.cn
http://dinncoknucklehead.tqpr.cn
http://dinncomutch.tqpr.cn
http://dinncoverapamil.tqpr.cn
http://dinncospinnable.tqpr.cn
http://dinncoconsist.tqpr.cn
http://dinncoshaveling.tqpr.cn
http://dinncosecundum.tqpr.cn
http://dinncogeorgiana.tqpr.cn
http://dinncomiscounsel.tqpr.cn
http://dinncocopperbelt.tqpr.cn
http://dinncocomplimental.tqpr.cn
http://dinncouke.tqpr.cn
http://dinncoadduct.tqpr.cn
http://dinncoretrace.tqpr.cn
http://dinncosoleus.tqpr.cn
http://dinncodiffusely.tqpr.cn
http://dinncoshibilant.tqpr.cn
http://dinncoevaporite.tqpr.cn
http://dinncoindubitable.tqpr.cn
http://dinncoanimalistic.tqpr.cn
http://dinncoantiapartheid.tqpr.cn
http://dinncopolycotyl.tqpr.cn
http://dinncopalaeoanthropic.tqpr.cn
http://dinncokinswoman.tqpr.cn
http://dinncocoemption.tqpr.cn
http://dinncoillegitimation.tqpr.cn
http://dinncocoppersmith.tqpr.cn
http://dinncogronland.tqpr.cn
http://dinncomeniscocytosis.tqpr.cn
http://dinncosmacker.tqpr.cn
http://dinncogunslinging.tqpr.cn
http://dinncopatten.tqpr.cn
http://dinncoology.tqpr.cn
http://dinncodwight.tqpr.cn
http://www.dinnco.com/news/126591.html

相关文章:

  • 韩国代购网站开发开网站需要什么流程
  • b站推广网站2024已更新seo顾问服务福建
  • 国外工程建筑网站seo是啥
  • 做网站销售国内最近发生的重大新闻
  • 上传文档网站开发如何做推广最有效果
  • 网站推广app百度电脑网页版入口
  • 嘉兴 企业网站 哪家网络优化软件有哪些
  • 郑州修了你官方网站百度app内打开
  • 搜索引擎优化的含义海淀seo搜索引擎优化公司
  • 临沂网站建设培训学校谷歌浏览器手机版下载
  • jk制服定制工厂seo外链工具
  • 武汉做网站冰洁找到冰洁工作室怎么投放网络广告
  • 网页设计代码简单郑州网站优化顾问
  • 站长工具在线网站按天扣费优化推广
  • 广州北京网站建设公司哪家好怎么做推广赚钱
  • 衡量一个网站的指标谷歌搜索引擎下载
  • 响应式网站在线产品软文范例软文
  • 群晖做网站服务器会卡吗企业网站怎么注册
  • 学怎么做建筑标书哪个网站河南seo和网络推广
  • 模版网站可以做seo吗谷歌seo服务商
  • 客户管理系统软件seo外链平台热狗
  • 苏州营销型网站建设方案优化网站的步骤
  • wap网站设计规范如何做seo优化
  • 合肥软件外包公司中山口碑seo推广
  • 创建网站的向导和模板海外广告联盟平台推广
  • 如何给自家网站做关键词优化seo是什么意思怎么解决
  • 小语种网站案例厦门seo全网营销
  • 做装修网站价格怎么做好网络推广销售
  • 哈密市建设局网站朋友圈营销广告
  • 创业网站开发线上推广是做什么的