Format Painter - Macro

spyldbrat

Board Regular
Joined
May 5, 2002
Messages
211
Office Version
  1. 365
I have to create borders on a worksheet. The number of rows in my spreadsheet will vary with each use (can be more or less than the last time used). I am not the end user so I was hoping I could use format painter while recording a macro but that didn't seem to work? Is there another way around this?
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
I am looking to have the blue border in between H & I and O & P copy down to the last row of data. The last row will change each time the spreadsheet is used.


1600274113280.png
 

Attachments

  • 1600274027712.png
    1600274027712.png
    46 KB · Views: 3
Upvote 0
How about
VBA Code:
Sub spyldbrat()
   With Range("H" & Rows.Count).End(xlUp)
      With Range("H1:H" & .Row & ",O1:O" & .Row).Borders(xlEdgeRight)
         .Color = vbBlue
         .Weight = xlThick
      End With
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,526
Messages
6,114,136
Members
448,551
Latest member
Sienna de Souza

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