Excel vba help needed
Closed
grs
-
Jul 30, 2009 at 04:54 PM
rosswduncan Posts 1 Registration date Friday July 31, 2009 Status Member Last seen August 1, 2009 - Aug 1, 2009 at 01:05 PM
rosswduncan Posts 1 Registration date Friday July 31, 2009 Status Member Last seen August 1, 2009 - Aug 1, 2009 at 01:05 PM
Related:
- Excel vba help needed
- Number to words in excel formula without vba - Guide
- Vba case like - Guide
- How to open vba in excel mac - Guide
- Excel marksheet - Guide
- Excel apk for pc - Download - Spreadsheets
1 response
rosswduncan
Posts
1
Registration date
Friday July 31, 2009
Status
Member
Last seen
August 1, 2009
Aug 1, 2009 at 01:05 PM
Aug 1, 2009 at 01:05 PM
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