VBA learner ITG
Active Member
- Joined
- Apr 18, 2017
- Messages
- 272
- Office Version
- 365
- Platform
- Windows
- MacOS
[FONT="]Good evening peers,[/FONT]
[FONT="]I am trying to figure out a logical way of deleting the highlighted rows in RED on the attached example workbook.[/FONT]
[FONT="]the data is variable so it can change location and im trying to determine what logical approach i would take to delete the unncessary rows generated.[/FONT]
[FONT="]I have tried with the below code and my logic is off and i could do putting this out there getting advice from my peers!
[/FONT]
https://zackcarter.wetransfer.com/d...17f44a8d9cf2acca95da81fd20171211183406/4ddd8c
[FONT="]I am trying to figure out a logical way of deleting the highlighted rows in RED on the attached example workbook.[/FONT]
[FONT="]the data is variable so it can change location and im trying to determine what logical approach i would take to delete the unncessary rows generated.[/FONT]
[FONT="]I have tried with the below code and my logic is off and i could do putting this out there getting advice from my peers!
[/FONT]
Code:
[COLOR=#000000][FONT=Courier]Worksheet.Select "EHL"[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier]myVal = Range("Z1").Value[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier]LastRow = Cells(Rows.count, "K").End(xlUp).Row[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier]Application.ScreenUpdating = False[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier]Columns("Z").Insert[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier]With Range("I6:I" & LastRow)[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] .Formula = "=IF(I6=" & myVal & ",1,"""")"[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] .Value = .Value[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] On Error Resume Next[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] .SpecialCells(xlCellTypeBlanks).EntireRow.DELETE[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] [/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] Columns("Z:Z").Select[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] Selection.DELETE Shift:=xlToLeft[/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] [/FONT][/COLOR][COLOR=#000000][FONT=Courier][/FONT][/COLOR][COLOR=#000000][FONT=Courier] End With [/FONT][/COLOR]
https://zackcarter.wetransfer.com/d...17f44a8d9cf2acca95da81fd20171211183406/4ddd8c