Hi guys just another quickie, the below code I am using to copy data is fine, but I need it to either overwrite the existing data on the sheet it is pasted to or to clear the data first before copying, the starred line in the code below I have been using in different places in the code but it does not seem to work, the range of data to be cleared is at most A2:AC198, but can be only a few rows.
scouse13
[code]
Private Sub CommandButton27_Click()
'ws2.Range("A2:AC198").ClearContents***************
Dim ws1 As Worksheet, ws2 As Worksheet
Dim lr As Long, x As Long, count As Long
Set ws1 = Sheets("Records")
Set ws2 = Sheets("WeeklyRawData")
lr = ws1.Range("A" & Rows.count).End(xlUp).Row
count = 2
For x = 2 To lr
If ws1.Cells(x, 25).Text = Me.TextBox11.Text Then
ws1.Range(ws1.Cells(x, 1), ws1.Cells(x, 29)).Copy Destination:=ws2.Range("A" & count)
count = count + 1
End If
Next x
ws2.Select
Sheets("WeeklySummery").Select
Unload Me
End Sub
[code/]
Bookmarks