kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Hi, I wanna copy just the part of the rows with data . Here the data range is column B to Column H .
How do I do that?
The code down here copies the entire rows which I wanna avoid.
Thanks
Kelly
How do I do that?
The code down here copies the entire rows which I wanna avoid.
Thanks
Kelly
Code:
Sub AnotherLoop_1063452()
Dim r As Range, rng As Range, rng1 As Range, b As Boolean
Dim arr As Variant
Application.ScreenUpdating = False
Set rng = Range("C1:C" & Cells(Rows.Count, "C").End(xlUp).Row)
b = False
arr = Split(Application.InputBox("Please enter two 2-digit numbers separated by a comma."), ",")
If UBound(arr) <> 1 Then
MsgBox "Your entry is invalid. Please try again."
Exit Sub
End If
For Each r In rng
If InStr(r.Value, arr(0)) > 0 And InStr(r.Value, arr(1)) > 0 Then
b = True
On Error GoTo nxt
Set rng1 = Application.Union(rng1, r)
End If
Next r
If b = True Then
' rng.Rows.Hidden = True
' rng1.EntireRow.Hidden = False
' ActiveWindow.ScrollRow = rng1.Row
rng1.EntireRow.Copy
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.Paste
Else
MsgBox "No match found."
End If
Exit Sub
nxt:
Set rng1 = r
On Error GoTo 0
Resume Next
End Sub