delete 2 dynamic ranges with VBA

J

John

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
 
I

isabelle

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 :
 
I

isabelle

thankfully it works despite my misspellings,
glad i could help

isabelle

Le 2013-01-08 16:06, John a écrit :
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top