border around some cells

KlausW

Active Member
Joined
Sep 9, 2020
Messages
379
Office Version
  1. 2016
Platform
  1. Windows
Hi all Excel helpers

Someone who can help, I want to put border around some cells. If I write A9 in cell J6 and I3511 in cell J7, all cells between the 2 must have a border around also in the middle. It has to be flexible, so if I change the numbers in J6 and J7 the border has to change too.

All help will be appreciated.

Best regards

Klaus W
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try:
VBA Code:
Sub border()
Range(Cells(Range(Range("J6").Text).Row, Range(Range("J6").Text).Column), _
Cells(Range(Range("J7").Text).Row, Range(Range("J7").Text).Column)).Borders.LineStyle = xlContinuous
End Sub
 
Upvote 0
Solution
Try:
VBA Code:
Sub border()
Range(Cells(Range(Range("J6").Text).Row, Range(Range("J6").Text).Column), _
Cells(Range(Range("J7").Text).Row, Range(Range("J7").Text).Column)).Borders.LineStyle = xlContinuous
End Sub
Great, thank you so much for that solution. It was just as it should be. Have a nice day. Many thanks KW
 
Upvote 0

Forum statistics

Threads
1,215,046
Messages
6,122,855
Members
449,096
Latest member
Erald

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