counting problem in excel

0

experts I have a problem with this macro, I execute it but the result in each cell is one of more, how can I improve it in all the orange columns the macro ends its count until the last blank cell of the columns "a; d" and I want it to end its count until the last number of the column "a; d" thanks

Sub NoSalenDesde()
Application.ScreenUpdating = False
Range("G16:N25").ClearContents
For x = 0 To 9
   Range("G" & x + 16) = x
   Range("I" & x + 16) = x
   Range("K" & x + 16) = x
   Range("M" & x + 16) = x
Next
'--
For x = Range("A" & Rows.Count).End(xlUp).Row - 99 To Range("A" & Rows.Count).End(xlUp).Row
   Range("H" & 16 + Range("A" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x + 1
   Range("J" & 16 + Range("B" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x + 1
   Range("L" & 16 + Range("C" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x + 1
   Range("N" & 16 + Range("D" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x + 1
Next
'--
Range("G16:H25").Sort Key1:=Columns("H"), Key2:=Columns("G"), Order1:=xlDescending
Range("I16:J25").Sort Key1:=Columns("J"), Key2:=Columns("I"), Order1:=xlDescending
Range("K16:L25").Sort Key1:=Columns("L"), Key2:=Columns("K"), Order1:=xlDescending
Range("M16:N25").Sort Key1:=Columns("N"), Key2:=Columns("M"), Order1:=xlDescending
End Sub
    
asked by Jhon Fredy Murcia Rodriguez 15.02.2018 в 15:30
source

1 answer

0

In the second for , the +1

For x = Range("A" & Rows.Count).End(xlUp).Row - 99 To Range("A" & Rows.Count).End(xlUp).Row
   Range("H" & 16 + Range("A" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x
   Range("J" & 16 + Range("B" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x
   Range("L" & 16 + Range("C" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x
   Range("N" & 16 + Range("D" & x)) = Range("A" & Rows.Count).End(xlUp).Row - x
Next
    
answered by 16.02.2018 / 18:43
source