本文介绍了填写特定列的特定文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Stackoverflow和VBA领域的新手.实际上,我的代码需要一些帮助.
I am newbie in here in Stackoverflow and in the VBA Field. Actually I need some help with my code.
我创建了一个VBA(宏),似乎我的代码丢失了.
I have created a VBA(macro) and it seems there is missing with my code.
场景:
如果B3列有答案("FLAT"或"PER")应适用于与A3列相同的所有列
if column B3 has an answer(either: "FLAT" or "PER") should be applicable to all column which is same in Column A3
例如
如果A3直到A500,那么B3直到B500也有答案("FLAT"或"PER").
if A3 until A500 then B3 until B500 has also an answer (either: "FLAT" or "PER").
Sub exe()
Dim number As Integer, result As String
number = Range("a1").Value
If number <= 1 Then
result = "Flat"
Else: result = "Per"
End If
Range("b1").Value = result
End Sub
推荐答案
您是否正在寻找类似的东西:
Are you look for something like this:
Sub exe()
Dim LastRow As Long, i As Long
With ThisWorkbook.Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For i = 1 To LastRow
If .Range("A" & i).Value = 0.5 Then
.Range("B" & i).Value = "FLAT"
ElseIf .Range("A" & i).Value = 2 Then
.Range("B" & i).Value = "PER"
End If
Next i
End With
End Sub
这篇关于填写特定列的特定文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!