gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,341
- Office Version
- 365
- Platform
- Windows
This code works perfectly only if there is data in A3 down.
how can I check to see if there is data before it performs the clear contents. if there is data, I want to clear it and then paste in the new data. If there isnt data then just paste in the new data
Note I am working with someone else workbook so the code below wont work. The tab is protected .
Thanks
how can I check to see if there is data before it performs the clear contents. if there is data, I want to clear it and then paste in the new data. If there isnt data then just paste in the new data
Code:
Sub PopoulateParts()
'1B
Dim lr As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
Parts.Range("A3:M" & lr).Select
Selection.ClearContents
DataMartParts.ListObjects("dmParts").DataBodyRange.Copy Parts.Range("A3")
End Sub
Note I am working with someone else workbook so the code below wont work. The tab is protected .
Code:
With Parts.Range("A3").CurrentRegion
Cells(.Rows.Count, .Columns.Count).Select
Selection.ClearContents
End With
Thanks