Delete range

  • Thread starter Thread starter gavmer
  • Start date Start date
G

gavmer

Hi all,

Im having a problem with code deleting more than it should. With th
code below, i am running it multiple times with different buttons
Problem is, it tends to delete other data on occassions that is no
part of the range. I dont know why. The data it deletes is data paste
from another sheet where the code works ok? Does this mean anything? I
it the code???

Any ideas????

Cheers!!
 
sorry, here is the code:

Private Sub Commandbutton4_click()
Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet2")
Set rng = wsquote.Range("no278")
x = rng.Rows.Count
rng.Range("no278").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End Sub

Private Sub CommandButton5_Click()
Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet2")
Set rng = wsquote.Range("no268")
x = rng.Rows.Count
rng.Range("no268").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End Sub

Private Sub CommandButton6_Click()
Dim rng As Range, x As Single
Dim wsquote As Worksheet
Set wsquote = Worksheets("sheet2")
Set rng = wsquote.Range("no3")
x = rng.Rows.Count
rng.Range("no3").ClearContents
rng.Offset(0, 0).Resize(x).EntireRow.Delete
'Sheets("sheet 1").Range("range").ClearContents
End Su
 

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

Back
Top