Create a border around a range of dynamic cells

riedyp

Board Regular
Joined
Feb 13, 2020
Messages
88
Office Version
  1. 365
Platform
  1. Windows
Hello,
I have a table dependent on another table that users will input information. I am trying to make my table dynamic, meaning that I want the border to move up and down with the displayed values when it is updated by a command button.
For example, from my picture I would like the border to be around the range of B23 to H(newRow). I do not want a border inside of that dynamic range. Any suggestions on how one might do that? Thank you.
VBA Code:
Private Sub UpdateButton_Click()
'newRow = ActiveSheet.Cells(1000, 3).End(xlUp).Row 'Goes to the last updated cell
'ActiveSheet.Cells(newRow, 3).Select
Dim lRow As Long, newRow As Long
lRow = ActiveSheet.Cells(Rows.Count, 3).End(xlUp).Row
For newRow = lRow To 1 Step -1
    If ActiveSheet.Cells(newRow, 3) <> 0 Then Exit For
Next
ActiveSheet.Cells(newRow, 3).Select
ActiveSheet.Range("B" & newRow).Resize(, 8).Borders(xlEdgeBottom).Weight = xlThin 'Creates bottom border
'ActiveSheet.Range(Cells(24,2),Cells(newRow,8).BorderAround , xlThin
'I want to create a border on the left,right and bottom of a range from B24 to H"newRow"
End Sub
 

Attachments

  • updated.PNG
    updated.PNG
    27.7 KB · Views: 94
Thank you so much. Sorry for the inconsistencies in my pictures.
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,989
Messages
6,122,622
Members
449,093
Latest member
catterz66

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