求教各位高手,excel函数,大家帮忙啊!
4个回答
展开全部
alt+f11,复制进去
Sub 要变成()
Dim i, j, h As Integer
h = Sheet2.Range("b65536").End(xlUp).Row
j = Sheet2.Range("a65536").End(xlUp).Row
Sheet2.Range("c2:c10000").Clear
Sheet2.Range("a2:a" & j).Copy Range("c2")
For i = j To 3 Step -1
If Cells(i, 3) <> Cells(i - 1, 3).Value Then
Range("c" & i).Insert Shift:=xlDown
Cells(i, 3) = Cells(h, 2).Value
h = h - 1
End If
Next
End Sub
按下f5 运行
Sub 要变成()
Dim i, j, h As Integer
h = Sheet2.Range("b65536").End(xlUp).Row
j = Sheet2.Range("a65536").End(xlUp).Row
Sheet2.Range("c2:c10000").Clear
Sheet2.Range("a2:a" & j).Copy Range("c2")
For i = j To 3 Step -1
If Cells(i, 3) <> Cells(i - 1, 3).Value Then
Range("c" & i).Insert Shift:=xlDown
Cells(i, 3) = Cells(h, 2).Value
h = h - 1
End If
Next
End Sub
按下f5 运行
展开全部
在工作表插入一个ActiveX命令按钮,并编程如下:
Private Sub CommandButton1_Click()
Dim ia As Integer, ib As Integer, ic As Integer
Range("c2:c65536").ClearContents
ib = 2
Range("C2").Value = Range("A2").Value
ic = 3
For ia = 3 To Range("A65536").End(xlUp).Row
If Range("A" & ia).Value = Range("A" & ia - 1).Value Then
Range("C" & ic).Value = Range("A" & ia).Value
Else
Range("C" & ic).Value = Range("B" & ib).Value
ic = ic + 1
ib = ib + 1
Range("C" & ic).Value = Range("A" & ia).Value
End If
ic = ic + 1
Next ia
End Sub
Private Sub CommandButton1_Click()
Dim ia As Integer, ib As Integer, ic As Integer
Range("c2:c65536").ClearContents
ib = 2
Range("C2").Value = Range("A2").Value
ic = 3
For ia = 3 To Range("A65536").End(xlUp).Row
If Range("A" & ia).Value = Range("A" & ia - 1).Value Then
Range("C" & ic).Value = Range("A" & ia).Value
Else
Range("C" & ic).Value = Range("B" & ib).Value
ic = ic + 1
ib = ib + 1
Range("C" & ic).Value = Range("A" & ia).Value
End If
ic = ic + 1
Next ia
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个不用函数的,应是用vba代码。
追问
Vba是什么代码啊!
Vba是什么代码啊!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询