1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
| Sub ComparisonRank4()
Dim LastNRow, LastPRow, LastRRow, LastXRow, rwR, rwRf, rwX, rwXf As Long
Application.ScreenUpdating = True
Application.ScreenUpdating = False
LastGRow = Cells(Rows.Count, "G").End(xlUp).Row
Range("N3:Q" & LastGRow + 1).ClearContents
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
'GOAL 1: DETERMINE IF THERE WAS A CHANGE IN RANK
'Scenario 1: Change in rank and features -
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
Range("R1:AE" & LastGRow).ClearContents
Call deleteR1dups
Call deleteR2dups
Call DeleteDupsInR1andR2
'CHECK RANK
For rwX = 3 To LastXRow
For rwR = 3 To LastRRow
LastNRow = Cells(Rows.Count, "N").End(xlUp).Row
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "AB") = Cells(rwR, "V") Then GoTo rwx_NEXT 'Same rank so skip
If Cells(rwX, "X") <> Cells(rwR, "R") Then GoTo rwx_NEXT 'Not the same Site so skip
If Cells(rwX, "X") = Cells(LastNRow, "N") Then GoTo rwx_NEXT 'Same Site as Previous Site in column N, so skip
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "AB") <> Cells(rwR, "V") Then 'Yes Rank has changed so continue
Cells(LastPRow + 1, "N") = Cells(rwX, "X")
Cells(LastPRow + 1, "O") = Cells(rwX, "Y")
Cells(LastPRow + 1, "P") = "Rank"
pc = Application.Round((Cells(rwX, "AA") / Cells(rwR, "U") - 1) * 100, 2)
Cells(LastPRow + 1, "Q") = "New: " & Cells(rwX, "AB") & ", " & " Old: " & Cells(rwR, "V") & ", PNR % Change: " & pc
End If
'CHECK FEATURES
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "T") = Cells(rwR, "Z") Then
Call FindNEWFeatures1
Call FindOLDFeatures1
Cells(LastPRow + 2, "P") = "Features"
Cells(LastPRow + 2, "Q") = "New: " & Cells(LastPRow + 1, "AD") & "Old: " & Cells(LastPRow + 1, "AE")
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "T") <> Cells(rwR, "Z") Then GoTo rwx_NEXT
End If
rwx_NEXT:
Next rwR
Next rwX
Range("AD3:AE" & LastXRow).ClearContents
Application.ScreenUpdating = True
End Sub
Sub ComparisonFeatures4()
Dim LastNRow, LastPRow, LastRRow, LastXRow, rwR, rwRf, rwX, rwXf As Long
'Scenario 3: No change in rank, but change in features
'If there is a change in features, show what was deleted and what was added...don't show any features if no features changed
Application.ScreenUpdating = False
Call CheckIfNew
Call FindNEWFeatures
Call CheckIfOld
Call FindOLDFeatures
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
Range("R1:AE" & LastXRow).ClearContents
'****************************
'Scenario 4: No change in rank OR features - Do NOT show in results - do NOTHING
'Delete R to V if Column R value = existing values in column N
LastNRow = Cells(Rows.Count, "N").End(xlUp).Row
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rwN = 3 To LastNRow
For rwR1 = 3 To LastRRow
If Cells(rwN, "N") <> "" And Cells(rwR1, "R") <> "" And Cells(rwN, "N") = Cells(rwR1, "R") Then
Range("R" & rwR1 & ":V" & rwR1).ClearContents
End If
Next rwR1
Next rwN
For rwN = 3 To LastNRow
For rwX1 = 3 To LastXRow
If Cells(rwN, "N") <> "" And Cells(rwX1, "X") <> "" And Cells(rwN, "N") = Cells(rwX1, "X") Then
Range("X" & rwX1 & ":AB" & rwX1).ClearContents
End If
Next rwX1
Next rwN
Application.ScreenUpdating = True
End Sub
Sub FeaturesNoRankChange4()
Dim LastNRow, LastPRow, LastRRow, LastXRow, rwR, rwRf, rwX, rwXf As Long
'List CHANGED FEATURES if rank unchanged
Application.ScreenUpdating = False
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rwXf = 3 To LastXRow
For rwRf = 3 To LastRRow
LastNRow = Cells(Rows.Count, "N").End(xlUp).Row
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
If Cells(rwRf, "R") = Cells(LastNRow, "N") Then GoTo rw2_NEXT
If Cells(rwRf, "R") = "" Then GoTo rw2_NEXT
If Cells(rwXf, "X") = "" Then GoTo rwr_NEXT
If Cells(rwXf, "X") = Cells(rwRf, "R") Then
Cells(LastPRow + 1, "N") = Cells(rwXf, "X")
Cells(LastPRow + 1, "O") = Cells(rwXf, "Y")
Cells(LastPRow + 1, "P") = "Features"
Call FindNEWFeatures1
Call FindOLDFeatures1
Cells(LastPRow + 1, "Q") = "New: " & Cells(LastPRow + 1, "AD") & "Old: " & Cells(LastPRow + 1, "AE")
If rwRf = LastRRow And rwXf = LastXRow Then GoTo PASSEM
End If
rw2_NEXT:
Next rwRf
rwr_NEXT:
Next rwXf
PASSEM:
Range("R1:AE" & LastXRow).ClearContents
Application.ScreenUpdating = True
End Sub
Sub deleteR1dups()
Dim dic As Object, a As Range, i As Long
Set a = Range("A1").CurrentRegion
Set dic = CreateObject("scripting.dictionary")
For i = 1 To a.Rows.Count
dic((a(i, 1).Value & Chr(2) & a(i, 3).Value)) = a.Rows(i)
Next i
With Application
Range("R1").Resize(dic.Count, 5) = .Transpose(.Transpose(dic.items))
End With
End Sub
Sub deleteR2dups()
Dim dic As Object, a As Range, i As Long
Set a = Range("G1").CurrentRegion
Set dic = CreateObject("scripting.dictionary")
For i = 1 To a.Rows.Count
dic((a(i, 1).Value & Chr(2) & a(i, 3).Value)) = a.Rows(i)
Next i
With Application
Range("X1").Resize(dic.Count, 5) = .Transpose(.Transpose(dic.items))
End With
End Sub
Sub DeleteR1dupsInR2()
Dim rwR, rwX, LastRRow, LastXRow As Long
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rwR = 3 To LastRRow
For rwX = 3 To LastXRow
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "Z") = Cells(rwR, "T") Then
Range("X" & rwX & ":AB" & rwX).ClearContents
End If
Next rwX
Next rwR
End Sub
Sub DeleteDupsInR1andR2()
Dim rwR, rwX, LastRRow, LastXRow As Long
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rwR = 3 To LastRRow
For rwX = 3 To LastXRow
If Cells(rwX, "X") = Cells(rwR, "R") And Cells(rwX, "Z") = Cells(rwR, "T") And Cells(rwX, "v") = Cells(rwR, "ab") Then
Range("X" & rwX & ":AB" & rwX).ClearContents
Range("R" & rwR & ":V" & rwR).ClearContents
End If
Next rwX
Next rwR
End Sub
Sub FindNEWFeatures1()
'List New Features Scenario 1
Dim Row As Integer
Dim rw, LastXRow, LastORow, LastPRow As Long
Dim Site As String
On Error GoTo ErrHandler
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
LastORow = Cells(Rows.Count, "O").End(xlUp).Row
Site = Cells(LastORow, "O")
Cells(LastPRow + 1, "AD").ClearContents
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rw = 3 To LastXRow
If Cells(rw, "X") = Site Then
Cells(LastPRow, "AD") = Cells(LastPRow, "AD") & Cells(rw, "Z") & ", "
End If
Next rw
ErrHandler:
Exit Sub
End Sub
Sub FindOLDFeatures1()
'List OLD Features Scenario 1
Dim rwR, LastRRow, LastPRow As Long
Dim Site As String
On Error GoTo ErrHandler
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
Site = Cells(LastPRow, "O")
Cells(LastPRow, "AE").ClearContents
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
For rwR = 3 To LastRRow
If Cells(rwR, "R") = Site Then
Cells(LastPRow, "AE") = Cells(LastPRow, "AE") & Cells(rwR, "T") & ", "
End If
Next rwR
ErrHandler:
Exit Sub
End Sub
Sub CheckIfNew()
Dim cnt As Integer
Dim rw, rwX, LastPRow, LastRRow, LastXRow, LastNRow As Long
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rw = 3 To LastRRow
cnt = 0
For rwX = 3 To LastXRow
If Cells(rw, "R") = Cells(rwX, "X") Then cnt = cnt + 1
Next rwX
If cnt >= 1 Then
GoTo NOT_NEW
Else
LastNRow = Cells(Rows.Count, "N").End(xlUp).Row
rwX = LastXRow
If Cells(LastNRow, "N") = Cells(rwX, "X") Then GoTo NOT_NEW
Cells(LastPRow + 1, "N") = Cells(rwX, "X")
Cells(LastPRow + 1, "O") = Cells(rwX, "Y")
Cells(LastPRow + 1, "P") = "New com"
'Call FindNewFeatures
'Cells(LastNRow + 1, "Q") = Cells(LastNRow + 1, "R")
'Range("R" & LastNRow + 1).ClearContents
'***************Inserts 'Last Rank' if Site is only in Release 1
'Cells(LastNRow + 1, "Q") = Cells(LastNRow + 1, "Q") & "Last Rank: " & Cells(rw, "E")
'***************
End If
NOT_NEW:
Next rw
End Sub
Sub FindNEWFeatures()
Dim Row As Integer
Dim rw, LastXRow, LastORow, LastPRow As Long
Dim Site As String
On Error GoTo ErrHandler
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
LastORow = Cells(Rows.Count, "O").End(xlUp).Row
Site = Cells(LastORow, "O")
Cells(LastPRow, "AD") = ""
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rw = 3 To LastXRow
If Cells(rw, "X") = Site Then
Cells(LastPRow, "AD") = Cells(LastPRow, "AD") & Cells(rw, "Z") & ", "
End If
Next rw
Cells(LastPRow, "Q") = "New Features: " & Cells(LastPRow, "AD") & " Rank: " & Cells(rw - 1, "AB")
'Range("R" & LastPRow & ":S" & LastPRow).ClearContents
ErrHandler:
Exit Sub
End Sub
Sub CheckIfOld()
Dim cnt As Integer
Dim rwR, rwX, LastRRow, LastXRow, LastNRow As Long
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
LastXRow = Cells(Rows.Count, "X").End(xlUp).Row
For rwR = 3 To LastRRow
cnt = 0
For rwX = 3 To LastXRow
If Cells(rwR, "R") = Cells(rwX, "X") Then cnt = cnt + 1
Next rwX
If cnt >= 1 Then
GoTo NOT_DISCONTINUED
Else
rwX = LastXRow
LastNRow = Cells(Rows.Count, "N").End(xlUp).Row
If Cells(rwR, "R") = Cells(LastNRow, "N") Then GoTo NOT_DISCONTINUED
Cells(LastNRow + 1, "N") = Cells(rwR, "R")
Cells(LastNRow + 1, "O") = Cells(rwR, "S")
Cells(LastNRow + 1, "P") = "Deleted com"
'Call FindOLDFeatures2
'Cells(LastNRow + 1, "Q") = Cells(LastNRow + 1, "R")
'Range("R" & LastNRow + 1).ClearContents
'***************Inserts 'Last Rank' if Site is only in Release 1
' Cells(LastNRow + 1, "Q") = Cells(LastNRow + 1, "Q") & "Last Rank: " & Cells(rw, "E")
'***************
End If
NOT_DISCONTINUED:
Next rwR
End Sub
Sub FindOLDFeatures()
Dim rwR, LastRRow, LastPRow As Long
Dim Site As String
On Error GoTo ErrHandler
LastPRow = Cells(Rows.Count, "P").End(xlUp).Row
Site = Cells(LastPRow, "O")
Cells(LastPRow, "AD").ClearContents
LastRRow = Cells(Rows.Count, "R").End(xlUp).Row
For rwR = 3 To LastRRow
If Cells(rwR, "R") = Site Then
Cells(LastPRow, "AD") = Cells(LastPRow, "AD") & Cells(rwR, "T") & ", "
End If
Next rwR
rwR = LastRRow
Cells(LastPRow, "Q") = "Old Features: " & Cells(LastPRow, "AD") & "Rank: " & Cells(rwR, "V")
ErrHandler:
Exit Sub
End Sub |
Partager