|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub AddSuffix()
- Dim i As Integer
- Dim columnJ As Range, columnK As Range, columnL As Range
-
- ' 获取输入数字
- Dim jValue As Integer
- Dim kValue As Integer
- Dim lValue As Integer
-
- jValue = Range("J2").Value
- kValue = Range("K2").Value
- lValue = Range("L2").Value
-
- ' 设置要处理的范围
- Set columnJ = Range("J2:J100")
- Set columnK = Range("K2:K100")
- Set columnL = Range("L2:L100")
-
- ' 遍历每个单元格,在对应单元格后添加后缀
- For i = 1 To columnJ.Rows.Count
- If Not IsEmpty(columnJ.Cells(i, 1)) Then
- columnJ.Cells(i, 1).Value = columnJ.Cells(i, 1).Value & "/" & jValue
- End If
- Next i
-
- For i = 1 To columnK.Rows.Count
- If Not IsEmpty(columnK.Cells(i, 1)) Then
- columnK.Cells(i, 1).Value = columnK.Cells(i, 1).Value & "/" & kValue
- End If
- Next i
-
- For i = 1 To columnL.Rows.Count
- If Not IsEmpty(columnL.Cells(i, 1)) Then
- columnL.Cells(i, 1).Value = columnL.Cells(i, 1).Value & "/" & lValue
- End If
- Next i
- End Sub
复制代码 |
|