|
Sub t101()
Dim newRange As Range
Set newRange = Application.InputBox(prompt:="请用鼠标选定一个区域", Title:="返回区域类所有大于0数字所在的行", Type:=8)
newRange.Select
Dim x As Integer, y As Integer, row_id As Integer, column_id As Integer
x = Selection.Rows.Count
y = Selection.Columns.Count
row_id = ActiveCell.Row
column_id = ActiveCell.Column
Dim x1 As Integer, y1 As Integer
Dim rg As Range, isx As Integer
For x1 = row_id To (row_id + x - 1) Step 1
For y1 = column_id To (column_id + x - 1) Step 1
If (IsNumeric(Cells(x1, y1))) And Cells(x1, y1) > 0 And isx = 0 Then
Set rg = Range(x1 & ":" & x1)
isx = 1
Else
If (IsNumeric(Cells(x1, y1))) And Cells(x1, y1) > 0 And isx >= 1 Then
Set rg = Union(rg, Range(x1 & ":" & x1))
End If
End If
Next y1
Next x1
|
|