我正在尝试编写一个宏,当单击一个按钮时,所有信息都会从一个电子表格转移到一个表单(也是excel表)上。我似乎无法做到一件事:当我到达表单底部时插入行。在表格的底部,在A栏中,它表示:附加。我想在每次接触这个单元格时插入一行。请帮忙!
例如:
for i = 1 to lastline
worksheet1.Range("A" & i).value = worksheet2.Range("A" & i)
if worksheet1.Range("A" & i).value contains "additional" 'please help me write this line
insert a line above this cell 'please help me write this line
end if
next i
请帮忙!!!提前致谢!如果我的问题有任何意义,请告诉我们。)
答案 0 :(得分:0)
Dim tmp, skip As Long
skip = 0
For i = 1 To lastline
tmp = worksheet2.Range("A" & i).Value
If LCase(tmp) Like "*additional*" Then skip = skip + 1
worksheet1.Cells(i + skip, 1).Value = tmp
Next i