Keebler
Board Regular
- Joined
- Dec 1, 2021
- Messages
- 176
- Office Version
- 2021
- Platform
- Windows
I am currently working on a project to copy a range from one worksheet to another removing empty or blank cells (rows) and pasting them into another ws at the bottom of the page.
so the problem is the last line.
Range(slist).Copy Range(trng).PasteSpecial(xlPasteValues)
unable to get the pastespecial property of the range class
im sure it is something stupid im missing...
no other errors are showing up --- at this time (and no i havent tried the removal of the blank rows yet)
VBA Code:
Sub copyto_test()
'define variables
Dim lrow As Long, srow As Long, erow As Long, crow As Long
Dim slist As String, srng As String, trng As String
Dim aws As Worksheet, sws As Worksheet, tws As Worksheet
Dim crg As Range
'set constants
Set aws = activesheet
Set tws = Sheets("INDEX")
lrow = tws.Range("e1") 'gets the last row of destination ws
If lrow <= 3 Then 'checks to make sure row is at least row 3
trng = tws.Range("a3").Address
Else
trng = tws.Range("a" & (lrow + 1))
End If
crow = aws.Range("e1") 'gets the last row of the current sheet
srow = aws.Range("h1") 'gets the first row of the current sheet
srng = Range("aa" & crow)
slist = ("k" & srow & ":" & srng)
Range(slist).Copy Range(trng).PasteSpecial(xlPasteValues)
End Sub
Range(slist).Copy Range(trng).PasteSpecial(xlPasteValues)
unable to get the pastespecial property of the range class
im sure it is something stupid im missing...
no other errors are showing up --- at this time (and no i havent tried the removal of the blank rows yet)