View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
isabelle isabelle is offline
external usenet poster
 
Posts: 587
Default 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