|
各位大神,标题太短可能表达不太清楚,先看下下面的图片
我想将某两列的内容组合到另外一列,三列位置都不是固定的,通过InputBox选择的,比如“姓”可能是在E列,“名”可能在F列,最后的“姓名”可能在G列
请帮忙看下下面的代码应该怎么修改。
- Sub TEST()
- On Error GoTo 100
- Dim rng As Range, rng1 As Range, rng2 As Range
- Set rng = Application.InputBox("转换功能", "选择姓氏所在区域", , , , , , 8)
- If rng Is Nothing Then Exit Sub
- Set rng1 = Application.InputBox("转换功能", "选择名字所在区域", , , , , , 8)
- If rng1 Is Nothing Then Exit Sub
- Set rng2 = Application.InputBox("转换功能", "选择姓名保存区域", , , , , , 8)
- If rng2 Is Nothing Then Exit Sub
- For Each rng In Selection
- rng2.Value = rng.Value & rng1.Value
- Next
- 100:
- End Sub
复制代码
|
|