[英]Excel VBA copy/paste range from 1 worksheet to another, same range pastes in next destination column each time
[英]copy data rows with NULL column to another range in the same worksheet
我正在Win 7上使用EXCEL 2010 vba。
我需要在一列中找到带有NULL的数据行。 并将它们复制到同一工作表中的另一个范围。
Option Explicit
Sub find_null_entries()
Dim ActSheet As Worksheet
Dim myRange As Range
Dim null_counter As Integer
Dim res_rng As Range
null_counter = 0
Set ActSheet = ActiveSheet
Set myRange = Selection
Range("D1").Value = "NULL rows"
For Each c In myRange
If c.Value Is "NULL" Then
null_count = null_count + 1
res_rng // copy the data entry to another range in the same worksheet, e.g. column D
End If
Next c
End Sub
例如
item value
person1 NULL // find this row and then copy the **WHOLE** row to another range in the same worksheet
person2 18
UPDATE
copy "person1 NULL" to another two columns
example: from A2:B2 to D2:E2
我有5000行数据,但可能有100行带有“ NULL”。 我需要找到它们并将其复制到toehr列。
任何帮助,将不胜感激 。
UPD:
Sub find_null_entries()
Dim myRange As Range
Dim c As Range
Dim null_counter As Long
Set myRange = Intersect(Selection, ActiveSheet.UsedRange)
Range("D1").Value = "NULL rows"
For Each c In myRange
If c.Value Like "*NULL*" Then
null_counter = null_counter + 1
Range("D1").Offset(null_counter).Resize(, 2).Value = c.Offset(, -1).Resize(, 2).Value
End If
Next c
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.