L
LoveCandle
Hi everybody,
I have these two codes:
The first one works on selecting specific records whose values are mor
than zero, and the other one is working on copying the selected record
by the first code to another sheet.
I tried to merge them in one code to get the same purpose but I foun
the second code move all records even those who have 0 value records
so I would like you please to help me in this matter.
First Code:
Code
-------------------
Sub Highlight ()
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
With ActiveSheet
FirstRow = 7
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iRow = FirstRow To LastRow
If .Cells(iRow, "A").Value > 0 Then
If myRng Is Nothing Then
Set myRng = .Cells(iRow, "A")
Else
Set myRng = Union(.Cells(iRow, "A"), myRng)
End If
End If
Next iRow
If myRng Is Nothing Then
MsgBox "No records to select"
Else
Intersect(myRng.EntireRow, .Range("a:j")).Select
End If
End With
End Su
-------------------
Second Code:
Code
-------------------
Sub Copy_Move()
Dim srcRng As Range
Dim destRng As Range
Dim Lrow As Long
Lrow = Cells(Rows.Count, "A").End(xlUp).Row
Set srcRng = ActiveSheet.Range("A7:J" & Lrow)
Set destRng = Sheets("100"). _
Cells(Rows.Count, "A").End(xlUp)(2)
srcRng.Copy Destination:=destRng
MsgBox "Data moved to the other sheet successfully", vbInformation, "Done"
End Su
I have these two codes:
The first one works on selecting specific records whose values are mor
than zero, and the other one is working on copying the selected record
by the first code to another sheet.
I tried to merge them in one code to get the same purpose but I foun
the second code move all records even those who have 0 value records
so I would like you please to help me in this matter.
First Code:
Code
-------------------
Sub Highlight ()
Dim iRow As Long
Dim FirstRow As Long
Dim LastRow As Long
With ActiveSheet
FirstRow = 7
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
For iRow = FirstRow To LastRow
If .Cells(iRow, "A").Value > 0 Then
If myRng Is Nothing Then
Set myRng = .Cells(iRow, "A")
Else
Set myRng = Union(.Cells(iRow, "A"), myRng)
End If
End If
Next iRow
If myRng Is Nothing Then
MsgBox "No records to select"
Else
Intersect(myRng.EntireRow, .Range("a:j")).Select
End If
End With
End Su
-------------------
Second Code:
Code
-------------------
Sub Copy_Move()
Dim srcRng As Range
Dim destRng As Range
Dim Lrow As Long
Lrow = Cells(Rows.Count, "A").End(xlUp).Row
Set srcRng = ActiveSheet.Range("A7:J" & Lrow)
Set destRng = Sheets("100"). _
Cells(Rows.Count, "A").End(xlUp)(2)
srcRng.Copy Destination:=destRng
MsgBox "Data moved to the other sheet successfully", vbInformation, "Done"
End Su