Excel vba help needed
Closed
grs
-
30 Jul 2009 à 16:54
rosswduncan Posts 1 Registration date Friday 31 July 2009 Status Member Last seen 1 August 2009 - 1 Aug 2009 à 13:05
rosswduncan Posts 1 Registration date Friday 31 July 2009 Status Member Last seen 1 August 2009 - 1 Aug 2009 à 13:05
Related:
- Excel vba help needed
- Excel vba find - Guide
- Vba excel mac - Guide
- Excel mod apk for pc - Download - Spreadsheets
- Excel vba send email with attachment - Guide
- Excel vba timer - Guide
1 response
rosswduncan
Posts
1
Registration date
Friday 31 July 2009
Status
Member
Last seen
1 August 2009
1 Aug 2009 à 13:05
1 Aug 2009 à 13:05
GRS --
I am also new to the board. Good location! I can help with #1. This code works -- called delete_garbage. Some comments. Pick the top where you want it to start, i used A1. It is just looping until it finds what it needs, deleting the entire rows along the way. You can also use "clearcontents" to erase the values in the rows it deleting the rows becomes a problem.
So it first looks for "itemID", then loops down to 1 row below Grand Total, then starts a delete row routing again. I set a loop counter... Otherwise it would just continue to delete rows forever! Happy coding!!!
RWD
Sub delete_garbage()
Range("A1").Select 'start at top
'LOOP UNITL CELL = "itemID"
Do Until ActiveCell.Value = "itemID" 'clean the trash
If ActiveCell.Value <> "itemID" Then
ActiveCell.EntireRow.Select
Selection.Delete shift:=xlUp
End If
Loop
'SEARCH FOR Grand Total
Dim loop_counter 'set a loop counter or it will run to the bottom!!
loop_couter = 1
Do Until ActiveCell.Value = "Grand Total"
If ActiveCell.Value <> "Grand Total" Then
ActiveCell.Offset(1, 0).Select
End If
Loop
ActiveCell.Offset(1, 0).Select 'go below Grand Total
'DELETE THE NEXT ROW THROUGH THE END OF THE LOOP COUNTER
Do Until loop_counter = 100
ActiveCell.EntireRow.Select
Selection.Delete shift:=xlUp
loop_counter = loop_counter + 1
Loop
End Sub
I am also new to the board. Good location! I can help with #1. This code works -- called delete_garbage. Some comments. Pick the top where you want it to start, i used A1. It is just looping until it finds what it needs, deleting the entire rows along the way. You can also use "clearcontents" to erase the values in the rows it deleting the rows becomes a problem.
So it first looks for "itemID", then loops down to 1 row below Grand Total, then starts a delete row routing again. I set a loop counter... Otherwise it would just continue to delete rows forever! Happy coding!!!
RWD
Sub delete_garbage()
Range("A1").Select 'start at top
'LOOP UNITL CELL = "itemID"
Do Until ActiveCell.Value = "itemID" 'clean the trash
If ActiveCell.Value <> "itemID" Then
ActiveCell.EntireRow.Select
Selection.Delete shift:=xlUp
End If
Loop
'SEARCH FOR Grand Total
Dim loop_counter 'set a loop counter or it will run to the bottom!!
loop_couter = 1
Do Until ActiveCell.Value = "Grand Total"
If ActiveCell.Value <> "Grand Total" Then
ActiveCell.Offset(1, 0).Select
End If
Loop
ActiveCell.Offset(1, 0).Select 'go below Grand Total
'DELETE THE NEXT ROW THROUGH THE END OF THE LOOP COUNTER
Do Until loop_counter = 100
ActiveCell.EntireRow.Select
Selection.Delete shift:=xlUp
loop_counter = loop_counter + 1
Loop
End Sub