nicolehalliday
Board Regular
- Joined
- May 19, 2010
- Messages
- 56
Hello,
I have been trying to figure out why my paste special isn't working for SO long, I'm close to giving up so hopefully someone else can spot the mistake! Is highlights yellow on the pastespecial line, but I don't understand why the paste location is invalid and have tried countless variations of below. Thanks for your help!
I have been trying to figure out why my paste special isn't working for SO long, I'm close to giving up so hopefully someone else can spot the mistake! Is highlights yellow on the pastespecial line, but I don't understand why the paste location is invalid and have tried countless variations of below. Thanks for your help!
Code:
Sub deletepastdiv()
Dim x As Long
Dim y As Long
Dim ticker As Range
Dim divfreq As Long
Dim csheet As Worksheet
Set csheet = Worksheets("Sheet2")
Dim histsheet As Worksheet
Set histsheet = Worksheets("Historical Divs")
Dim count As Long
Dim exdate As Date
Dim twodaysago As Date
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
startrow = 4
endrow = histsheet.Range("D" & startrow).End(xlDown).Row
hendrow = csheet.Range("D" & startrow).End(xlDown).Row
For x = startrow To endrow
twodaysago = csheet.Range("K2")
For y = startrow To hendrow
If csheet.Range("D" & x) < twodaysago Then
If endrow > 65535 Then
endrow = startrow - 1
exdate = csheet.Range("D" & y)
exdaterow = x
csheet.Range("D" & exdaterow, "L" & exdaterow).Cut
histsheets.Range("D:L" & endrow + 1).PasteSpecial
End If
End If
Next y
Next x
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub