como formatear rango con macro?

dvd

New Member
Joined
Apr 3, 2003
Messages
2
Tengo un prgrama que envia datos a excel. Finalmente tengo una matriz de datos que puede ser de a1:b20 por ejemplo
o b3:g30, es decir la matriz de datos no siempre es la misma, como puedo crear una macro que formatee el rango poniendole borde a cada celda del rango.
gracias por su ayuda :oops:
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Perdoname pero mi espanol es muy malo.

Si tienes este:
Book1
ABCDEF
1
236657366573665736657
336658366583665836658
436659366593665936659
536660366603666036660
636661366613666136661
736662366623666236662
8
Sheet1


Puedes usar este macro cambiar las celdas. Necesitas selectar las celdas que quieres cambiar:

Code:
Sub CambiarPorDatos()
Dim ThisCell As Range
    For Each ThisCell In Range(Selection.Address)
        ThisCell.Value = Format(ThisCell.Value, "ddddd")
    Next ThisCell
End Sub

O este:

Code:
Sub CambiarPorDatos()
Dim ThisCell As Range
    For Each ThisCell In Range(Selection.Address)
        ThisCell.NumberFormat = "m/d/yyyy"
    Next ThisCell
End Sub
Book1
ABCDEF
1
25/11/20005/11/20005/11/20005/11/2000
35/12/20005/12/20005/12/20005/12/2000
45/13/20005/13/20005/13/20005/13/2000
55/14/20005/14/20005/14/20005/14/2000
65/15/20005/15/20005/15/20005/15/2000
75/16/20005/16/20005/16/20005/16/2000
8
Sheet1
 
Upvote 0

Forum statistics

Threads
1,223,934
Messages
6,175,492
Members
452,649
Latest member
mr_bhavesh

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