Hi,
( Please refer to attached file for clear understanding....)
When the commandbutton1 is used to remove #REF! error, all the rows shift up.
This affects badly on to the other cells , their purpose size , references etc. I also can not place remaining pages in that sheet on the side of first table due to too many complications.
I have count function ( green) which counts number of rows having #REF! error.
I am looking for a VB code which will count number of #REF! rows being deleted ( by press of a command button1) and adds those many rows just below the last row in that page ( as shown in red).
Is it possible?
Sheet1 code is as follows
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 5 And Target.Cells.Count = 1 Then
Target.EntireRow.Copy Destination:=Sheets(2).Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
Target.EntireRow.Delete Shift:=xlUp
End If
End Sub
Sheet3 ( command button code is as follows)
Sub RemoveREFRows()
Dim delRNG As Range, REFrng As Range, REFfirst As Range
On Error Resume Next
With Sheets("Sheet3")
Set REFrng = .Cells.Find(What:="#REF", LookIn:=xlValues, LookAt:=xlPart)
If Not REFrng Is Nothing Then
Set REFfirst = REFrng
Set delRNG = REFrng
Do
Set delRNG = Union(delRNG, REFrng)
Set REFrng = .Cells.FindNext(REFrng)
Loop While REFrng.Address <> REFfirst.Address
delRNG.EntireRow.Delete xlShiftUp
Set REFrng = Nothing
Set REFfirst = Nothing
End If
End With
End Sub
Any help will be appreciated
Many thanks
Bookmarks