Microsoft Office Tutorials and References
In Depth Information
DELETE RECORDS IN VBA
Figure 147. h e BeforeUpdate procedure
formats the entries in the text boxes.
Summary: Although text boxes on user forms do not offer a numeric format
property, you can use code to format the values entered in the text box.
Source: http://www.mrexcel.com/forum/showthread.php?p=66754
Nate Oliver, Microsoft Excel MVP, provided this solution. He humbly serves as
MrExcel.com’s administrator, using the handle NateO. He resides in Minneapolis
and entertains rather sophisticated fi nance and IT projects.
DELETE RECORDS IN VBA
Challenge: You need to delete records that match a certain criterion, and you’d
like to do it by using a VBA macro.
Solution: The typical solution involves running a For Next loop backward,
from the last row up to row 1, checking each record and deciding whether
that record should be deleted. The code to delete all the records with S29 in
column D would be something like this:
Sub LoopWay()
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = FinalRow To 2 Step -1
If Cells(i, 4) = "S29" Then
Cells(i, 1).EntireRow.Delete
End If
Next i
End Sub
Richard Schollar offered code that achieves this task quickly and effi ciently by
using the Excel AutoFilter command to isolate the desired records and then the
SpecialCells property to delete only the visible cells.
 
 
Search JabSto ::




Custom Search