Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 ------------------- -- LoveCandl ----------------------------------------------------------------------- LoveCandle's Profile: http://www.excelforum.com/member.php...fo&userid=2861 View this thread: http://www.excelforum.com/showthread.php?threadid=48772 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Adding area codes only to phone numbers missing an area code | Excel Discussion (Misc queries) | |||
VBA code Required to Run the Multiple VBA Codes | Excel Discussion (Misc queries) | |||
Where 2 place the code? (Worksheet Codes Vs. Modules) | Excel Discussion (Misc queries) | |||
losing the leading zero when merging zip+4 postal code | Excel Discussion (Misc queries) | |||
When merging information not merging correctly | Excel Worksheet Functions |