Dunk4Divin
New Member
- Joined
- Aug 21, 2019
- Messages
- 16
- Office Version
- 365
- Platform
- Windows
Hi
I am struggling to find out why this code wont work it's copying a variable range of data to another sheet but fails at the final hurdle of pasting. I've tried a variety of versions of the line but no good.
Any help would be appreciated!
I am struggling to find out why this code wont work it's copying a variable range of data to another sheet but fails at the final hurdle of pasting. I've tried a variety of versions of the line but no good.
Any help would be appreciated!
Rich (BB code):
Sub ResetSummarySheet()
Application.ScreenUpdating = False
Sheets("Summary Filter").Select
ActiveSheet.Unprotect Password:="0159"
'Clears data below first row. The first row is then copied to the specified range
Dim Rval2 As Variant
Dim Cval2 As Variant
Sheets("CalcData").Select
Rval2 = ActiveSheet.Range("H2").Value
Cval2 = ActiveSheet.Range("H3").Value
Dim Rng2 As Variant
Sheets("Summary Filter").Select
Set Rng2 = Range(Cells(13, 1), Cells(Rval2, Cval2))
Rng2.Select
On Error GoTo EH:
Selection.Clear
' Sets range to copy line of "Summary Filter" and paste from top to bottom of current "Condensed Data" range
'set top row range using column count from CalcData sheet
EH:
Dim Cval As Variant
Sheets("CalcData").Select
' Summary Filter sheet Column count
Cval = ActiveSheet.Range("H3").Value
Dim Rval As Variant
Sheets("CalcData").Select
' Condensed Data sheet row count
Rval = ActiveSheet.Range("E2").Value
' Selects Summary Filtersheet and row to paste
Dim Rng As Variant
Sheets("Summary Filter").Select
ActiveSheet.Unprotect Password:="0159"
Call ClearFilters
Set Rng = Range("BO12:EB12")
Rng.Select
Selection.Copy
'Sets range to paste selected row into
ActiveSheet.Unprotect Password:="0159"
Set Rng = Range(Cells(12, 1), Cells(Rval + 10, Cval))
Rng.Select
Selection.Paste
Application.Goto Reference:=Range("A12"), Scroll:=True
Range("A12").Select
Sheets("Summary Filter").Select
Call GoToSummary
End Sub
Last edited by a moderator: