ejecutar codigo hasta el final de los datos

dragonfire33

Board Regular
Joined
Oct 7, 2021
Messages
90
Office Version
  1. 365
Platform
  1. Windows
como puedo ejecutar este codigo para ejecutar hasta donde este el ultimo dato numerico
VBA Code:
Sub LosQueMasSalen()
Application.ScreenUpdating = False
Range("AP3:AW12").ClearContents
For x = 0 To 9
   Range("AP" & x + 3) = x
   Range("AR" & x + 3) = x
   Range("AT" & x + 3) = x
   Range("AV" & x + 3) = x
Next
'--
For x = Range("A" & Rows.Count).End(xlUp).Row - 99 To Range("A" & Rows.Count).End(xlUp).Row
   Range("AQ" & 3 + Range("A" & x)) = Range("AQ" & 3 + Range("A" & x)) + 1
   Range("AS" & 3 + Range("B" & x)) = Range("AS" & 3 + Range("B" & x)) + 1
   Range("AU" & 3 + Range("C" & x)) = Range("AU" & 3 + Range("C" & x)) + 1
   Range("AW" & 3 + Range("D" & x)) = Range("AW" & 3 + Range("D" & x)) + 1
Next
'--
Range("AP3:AQ12").Sort Key1:=Columns("AQ"), Key2:=Columns("AP"), Order1:=xlDescending
Range("AR3:AS12").Sort Key1:=Columns("AS"), Key2:=Columns("AR"), Order1:=xlDescending
Range("AT3:AU12").Sort Key1:=Columns("AU"), Key2:=Columns("AT"), Order1:=xlDescending
Range("AV3:AW12").Sort Key1:=Columns("AW"), Key2:=Columns("AV"), Order1:=xlDescending
End Sub
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

¿ sin respuesta ?

 
Upvote 0
como puedo ejecutar este codigo para ejecutar hasta donde este el ultimo dato numerico
VBA Code:
Sub LosQueMasSalen()
Application.ScreenUpdating = False
Range("AP3:AW12").ClearContents
For x = 0 To 9
   Range("AP" & x + 3) = x
   Range("AR" & x + 3) = x
   Range("AT" & x + 3) = x
   Range("AV" & x + 3) = x
Next
'--
For x = Range("A" & Rows.Count).End(xlUp).Row - 99 To Range("A" & Rows.Count).End(xlUp).Row
   Range("AQ" & 3 + Range("A" & x)) = Range("AQ" & 3 + Range("A" & x)) + 1
   Range("AS" & 3 + Range("B" & x)) = Range("AS" & 3 + Range("B" & x)) + 1
   Range("AU" & 3 + Range("C" & x)) = Range("AU" & 3 + Range("C" & x)) + 1
   Range("AW" & 3 + Range("D" & x)) = Range("AW" & 3 + Range("D" & x)) + 1
Next
'--
Range("AP3:AQ12").Sort Key1:=Columns("AQ"), Key2:=Columns("AP"), Order1:=xlDescending
Range("AR3:AS12").Sort Key1:=Columns("AS"), Key2:=Columns("AR"), Order1:=xlDescending
Range("AT3:AU12").Sort Key1:=Columns("AU"), Key2:=Columns("AT"), Order1:=xlDescending
Range("AV3:AW12").Sort Key1:=Columns("AW"), Key2:=Columns("AV"), Order1:=xlDescending
End Sub
Si estás hablando de la última fila con datos pues podrías aplicar un xlDown, es similar al xlUp solo que hacia abajo y te coloca en la última fila con algún dato. También si quieres optimizar un poco la macro, en vez de rangos podrías optar por nombrar grupo de celdas.
Tal vez si explicaras mejor el tema podría ayudarte mejor, creo que estas funciones se pueden optimizar mucho.
 
Upvote 0

Forum statistics

Threads
1,221,513
Messages
6,160,242
Members
451,632
Latest member
purpleflower26

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top