ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   delete 2 dynamic ranges with VBA (https://www.excelbanter.com/excel-programming/447956-delete-2-dynamic-ranges-vba.html)

John[_34_]

delete 2 dynamic ranges with VBA
 
Hello to everybody,
I would like to delete only the values and not the various formatting
with a button plus a message (Are you sure to delete the datas?) the
following dynamic range:
-from B9:H9
-from A23:G? up to the last row contains data.
Can you please help?

Thanks and Regards
John

isabelle

delete 2 dynamic ranges with VBA
 
hi John,

Private Sub CommandButton1_Click()
Dim LastRow As Long
Dim Msg, Style, Title, Response

Msg = "Are you sure to delete the select datas?"
Style = vbYesNo + vbCritical + vbDefaultButton2
Title = "Clear Contents"
LastRow = Cells(Rows.Count, 1).End(xlUp).Row

Union(Range("B9:H9"), Range("A23:G" & LastRow)).Select
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then
Selection.ClearContents
End If
End Sub

isabelle


Le 2013-01-08 14:22, John a écrit :
Hello to everybody,
I would like to delete only the values and not the various formatting
with a button plus a message (Are you sure to delete the datas?) the
following dynamic range:
-from B9:H9
-from A23:G? up to the last row contains data.
Can you please help?

Thanks and Regards
John


John[_34_]

delete 2 dynamic ranges with VBA
 
Thank you Isabelle.
It is perfect!

Regards
John


isabelle

delete 2 dynamic ranges with VBA
 
thankfully it works despite my misspellings,
glad i could help

isabelle

Le 2013-01-08 16:06, John a écrit :
Thank you Isabelle.
It is perfect!

Regards
John



All times are GMT +1. The time now is 12:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com