EXCEL中如何编写VBA?以此判断循环多行单元格数值及赋值。
例如:判断A列1行=空值时,F列1行赋值为"=A2&B2&C2"If[a1]=0Then[F1]="=A2&B2&C2"EndIf由于我的列数是很多A1~A1000甚至以...
例如:
判断 A列1行=空值时, F列1行赋值为"=A2&B2&C2"
If [a1] = 0 Then
[F1] = "=A2&B2&C2"
EndIf
由于我的列数是很多 A1 ~ A1000 甚至以上,我需要一个循环语句
判断 A列1,2,3....行.
If [axxxx] = 0 Then
[Fxxxx] = "=Axxxx&Bxxxx&Cxxxx"
EndIf
如判断A1,条件为真, 则立即给F1赋值.A2真,F2赋值..... 不断循环向下行.
直至设定循环次数结束为止.
是用EXCEL的VBA实现,谢谢各位! 展开
判断 A列1行=空值时, F列1行赋值为"=A2&B2&C2"
If [a1] = 0 Then
[F1] = "=A2&B2&C2"
EndIf
由于我的列数是很多 A1 ~ A1000 甚至以上,我需要一个循环语句
判断 A列1,2,3....行.
If [axxxx] = 0 Then
[Fxxxx] = "=Axxxx&Bxxxx&Cxxxx"
EndIf
如判断A1,条件为真, 则立即给F1赋值.A2真,F2赋值..... 不断循环向下行.
直至设定循环次数结束为止.
是用EXCEL的VBA实现,谢谢各位! 展开
1个回答
展开全部
简单的循环
Sub test()
Dim i As Long
Dim endRow As Long
endRow = Range("A" & Rows.Count).End(xlUp).Row '获取末行
if endRow < 1 then exit sub
For i = 1 To endRow-1
if trim(range("A" & i).value) = "" then
Range("F" & i).Formula = "=A" & i+1 & "&B" & i+1 & "&C" & i+1
end if
Next i
End Sub
或者
Sub test()
Dim i As Long
Dim endRow As Long
endRow = Range("A" & Rows.Count).End(xlUp).Row '获取末行
if endRow < 0 then exit sub
For i = 1 To endRow
if trim(range("A" & i).value) = "" then
Range("F" & i).Formula = "=A" & i & "&B" & i & "&C" & i
end if
Next i
End Sub
二段代码,前面是f1=(=a2&b2&c2),后一段是f1=(=a1&b1&c1)
Sub test()
Dim i As Long
Dim endRow As Long
endRow = Range("A" & Rows.Count).End(xlUp).Row '获取末行
if endRow < 1 then exit sub
For i = 1 To endRow-1
if trim(range("A" & i).value) = "" then
Range("F" & i).Formula = "=A" & i+1 & "&B" & i+1 & "&C" & i+1
end if
Next i
End Sub
或者
Sub test()
Dim i As Long
Dim endRow As Long
endRow = Range("A" & Rows.Count).End(xlUp).Row '获取末行
if endRow < 0 then exit sub
For i = 1 To endRow
if trim(range("A" & i).value) = "" then
Range("F" & i).Formula = "=A" & i & "&B" & i & "&C" & i
end if
Next i
End Sub
二段代码,前面是f1=(=a2&b2&c2),后一段是f1=(=a1&b1&c1)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询