所以我想要做的是,我希望能够在Excel中按一个按钮来连接多个列。我以前见过它但不确定如何创建它。我有从B2开始的信息:B100,到J2:J100,需要在A列中将所有内容放在一起,用" _"对应于A2中的每一行:A100。
B2:J100之间的数据经常变化,这就是为什么我希望将它作为按钮而不仅仅是连接功能并一直向下拖动的原因。只是寻找看起来更干净的东西。
任何帮助都会很棒!
-Maykid
答案 0 :(得分:1)
但如果你真的需要一个VBA解决方案,那就是:
Sub Test()
For i = 2 To 100
Range("A" & i).Value = Range("B" & i).Value & "_" & Range("J" & i).Value
Next i
End Sub
答案 1 :(得分:0)
如果你想连接忽略空白单元格,你可以这样做。
MainWindow window = new MainWindow();
// Visibility attempts
window.Loaded += async (a, b) =>
{
await Authentication();
// Undoing the above visibility attempts
SplashScreen.Close();
};
SplashScreen.Show("Authenticating");
new Application().Run(window);
更新 2:如果要完全忽略包含空白字段的任何行,请使用else语句。
Dim temp As String
For Row = 2 To 100
temp = ""
For col = 2 To 10
If Cells(Row, col) <> "" Then
If temp <> "" Then temp = temp & "_"
temp = temp & Cells(Row, col)
End If
Next col
Cells(Row, 1) = temp
Next Row
答案 2 :(得分:0)
Sub Test()
Dim iRow As Long
For iRow = 2 To 100
With Range("B:J").Rows(iRow)
If WorksheetFunction.CountBlank(.Cells)>0 Then .SpecialCells(xlCellTypeBlanks).Value = "|"
Cells(iRow, 1).Value = Replace(Join(Application.Transpose(Application.Transpose(.Value)),"_"), "_|_","")
.Replace what:="|", Replacement:= "", LookAt:=xlWhole
End With
Next
End Sub