【问题标题】:Excel VBA: Move name for multiple sections [closed]Excel VBA:移动多个部分的名称[关闭]
【发布时间】:2020-10-28 12:08:45
【问题描述】:

我有一个这样构建的不幸数据集,我需要将“姓名:”(名字姓氏)移到每个产品成本的右侧,无论有多少条目以某种方式存在,但无法计算自动执行此操作的逻辑(VBA):

..标题“名称”也需要在“成本”一词旁边..

【问题讨论】:

    标签: excel vba for-loop


    【解决方案1】:
    Sub code()
    'Define variables
    Dim rng As Range
    Dim cell As Range
    
    'Find non-empty cells in column B
    Set rng = Range("B:B").SpecialCells(xlCellTypeConstants)
    
    'move each non empty cell from column B by 2 rows and 4 columns
    For Each cell In rng
        cell.Cut Range(cell.Offset(2, 4).Address)
    Next cell
    
    End Sub
    

    【讨论】:

    • 谢谢!不准确,但它可以解决问题。我认为其余的都不容易清理。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多