Add a row below an activebutton, keeping the format without resizing the button

guippezzini

New Member
Joined
Jun 1, 2018
Messages
2
Hi. I would like to click at the "+" button and add an entire blank row below the "button", so I can put a new hour with new value for a specific day. It is important to keep the format, fill color, and to not resize the button (when I insert a row manually, the button gets bigger to the cell below). I've searched the internet a lot and didn't find a good macro to do it.
The new row must not have the "+"button, or + sign.
Thanks!


DayAddHourValue
01+08:002
02+08:004
Sum6

<tbody>
</tbody>
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
this example code does not uses buttons.
if you select a cell that contains a "+" this little piece of code will insert a blank line below that line.
Right click on the sheetlabel, select View code and paste this
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Count = 1 And Target.Value = "+" Then
        Rows(Target.Row + 1).Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    End If
End Sub
the sum formula: if you use =SUM(INDIRECT("D2:D"&ROW(D3)))
it automatically adapts to the extra line inserted
 
Upvote 0
Thank you for your answer! I still want to make it work using the button.. If this is not possible I will use your method
 
Upvote 0

Forum statistics

Threads
1,216,098
Messages
6,128,812
Members
449,468
Latest member
AGreen17

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