Macro to adjust border at last cell entry

bkyarbro

Board Regular
Joined
Nov 2, 2007
Messages
69
Hi,

I have a tracking report I built that is sorted with a macro. I can enter a new record in and the macro will autonumber and sort the worksheet based on my parameters. The thing I'm struggling with is a simple formatting issue.

There is a border at the bottom of the report that should adjust to include every new cell entry. Primarily, I'm gauging this off column C where if a new project comes into our queue, I want to autonumber, sort, and adjust the border. Well, I've done 2 out 3. I can't figure out the syntax for the border.

Here is an example:

The border has to be reformatted every time I add a new entry. So, the border would end after number 87 (from the last time manually formatted). How would I add the logic to make the border include the last entry in column C (88)? So, the border should now encompass number 88 as well.

81 Quarterly Securities Transaction Report Enhancement
82 Litigation / History Database
83 TU012 Corporate Trust AddVantage form enhancements
84 NRRE Operational Committee formation
85 Charitable Trust (E&F) LOB Transition
86 Trust Incentive Automation - Phase III
87 Custody Database Update
88 test
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try this:-
After you enter data in "C" the previous line above, is removed and a new line is created below.
Code:
Private [COLOR=navy]Sub[/COLOR] Worksheet_SelectionChange(ByVal Target [COLOR=navy]As[/COLOR] Range)
[COLOR=navy]Dim[/COLOR] Lst [COLOR=navy]As[/COLOR] [COLOR=navy]Integer[/COLOR]
[COLOR=navy]If[/COLOR] Target.Column = 3 [COLOR=navy]Then[/COLOR]
Lst = Range("c" & rows.Count).End(xlUp).row
rows(Lst - 1).EntireRow.Borders(xlEdgeBottom).LineStyle = xlNone
[COLOR=navy]With[/COLOR] rows(Lst).EntireRow.Borders(xlEdgeBottom)
        .LineStyle = xlSingle
        .Weight = xlThick
        .ColorIndex = xlAutomatic
[COLOR=navy]End[/COLOR] With
[COLOR=navy]End[/COLOR] [COLOR=navy]If[/COLOR]
[COLOR=navy]End[/COLOR] [COLOR=navy]Sub[/COLOR]
Regards Mick
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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