Delete Row but keep formating and formulas

jerrypatos

New Member
Joined
May 10, 2022
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I need to delete the range (B:H) but keep the formula at H & G at the next row. For some reason it looses the formula.

The below code do the same thing (thanks to @Fluff) , but Insert row and working fine. Now I need to delete a row but not impact formulas at H&G


Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)

If Not Intersect(Target, Columns("B:H")) Is Nothing Then

Cancel = True

With Range("B" & Target.Row).Resize(, 7)

.Offset(1).Insert xlDown

.Resize(2).FillDown

End With

End If

End Sub


Worksheet

protect2.xlsx
ABCDEFGH
1DESCRPCPRICEsome datasome data
200,00 €
300,00 €
400,00 €
5JERRYPATOS253.250,00 €581.250,00 €
6JERRYPATOS253.250,00 €581.250,00 €
7JERRYPATOS253.250,00 €581.250,00 €
8JERRYPATOS253.250,00 €581.250,00 €
9JERRYPATOS253.250,00 €581.250,00 €
10JERRYPATOS253.250,00 €581.250,00 €
11JERRYPATOS253.250,00 €581.250,00 €
12JERRYPATOS253.250,00 €581.250,00 €
13JERRYPATOS253.250,00 €581.250,00 €
14JERRYPATOS253.250,00 €581.250,00 €
15JERRYPATOS253.250,00 €581.250,00 €
16JERRYPATOS253.250,00 €581.250,00 €
17JERRYPATOS253.250,00 €581.250,00 €
1800,00 €
1900,00 €
2000,00 €
Sheet1
Cell Formulas
RangeFormula
G2:G20G2=C2*0.2
H2:H20H2=C2*D2


Please give me a idea what can I do.

Cheers
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
I think that I have figure it out

The below code is working but I need to insert On error resume next to work

VBA Code:
 If Not Intersect(Target, Columns("B:H")) Is Nothing Then
Cancel = True
On Error Resume Next
    With Range("B" & Target.Row).Resize(, 7)
      .Offset().Delete xlUp
      .Resize(, 5).FillUp
      .Offset(1).Resize(, 5).ClearContents
   End With
End If

Do anyone has an idea why is that?

Cheers
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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