zombiemaster
Board Regular
- Joined
- Oct 27, 2009
- Messages
- 245
I'm trying to look at data and each time it finds the word "TYPE" in column G, it does some formatting and copy/paste stuff, then moves on to the next instance. I figured a DO LOOP would work best, and it works for what I need until it reaches the last "TYPE", then crashes. I'm not very familiar with the DO LOOP so I'm sure it's a simple fix. I want it to reach the last instance of "TYPE" then move out of the loop to continue the rest of the macro...all help is appreciated!
I think the problem might be with where I put the "Do While ActiveCell.Value <> Empty" line. And yes, I know my code is messy (kind of like my life...lol) so appreciate any extra help as well.
Thanks for looking!
~ZM~
Code:
Range("B56600").Select
Selection.End(xlUp).Select
endrow$ = ActiveCell.Row
Range("G1").Select
startRow$ = ActiveCell.Row
Range("G" & startRow & ":G" & endrow).Select
Selection.Find(What:="TYPE", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-5, -1).Select
Selection.Copy
ActiveCell.Offset(7, -5).PasteSpecial
Do While ActiveCell.Value <> Empty
ActiveCell.Offset(0, 6).Select
startRow$ = ActiveCell.Row
Range("G" & startRow & ":G" & endrow).Select
Selection.Find(What:="TYPE", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Offset(-5, -1).Select
Selection.Copy
ActiveCell.Offset(7, -5).PasteSpecial
Loop
I think the problem might be with where I put the "Do While ActiveCell.Value <> Empty" line. And yes, I know my code is messy (kind of like my life...lol) so appreciate any extra help as well.
Thanks for looking!
~ZM~