Creating chart on one sheet based on dynamic auto filter in another sheet - returning incorrect range - excel

I have an excel workbook with multiple sheets. The first sheet is a dashboard on which I display charts based on data from other sheets.
I have a sheet called Daily Score. In it are three columns:
User ID, Sum_PointsAdded, Day_Timestamp
On any given day, a user can have a row inserted with the points they added and the date added.
The header row starts on A3 and has auto filter applied.
On the dashboard I have created a button that asks the user to insert a UserID via an input box. Based on that data, I filter the data to show only that user's score.
A sample result would be:
User ID Sum_PointsAdded Day_Timestamp
777 38 28/3/19
777 11 20/3/19
777 44 2/4/19
777 24 13/5/19
The chart I add is a line chart and should show only one line (and one entry type in the legend).
The X axis is the date and the Y axis is the score.
If I manually use the filter on the Daily Score sheet, and then I click the button on the Dashboard sheet and request the filter, the chart appears OK. However, if I simply click the chart button on the dashboard and don't fiddle with the filter, the chart I get has a line for Sum_PointsAdded and a line for Day_Timestamp (that I shouldn't get) and no line for score.
The legend has four entries: Score, Sum_PointsAdded, Day_Timestamp and Series4
I'm assuming I'm doing something wrong with the filter or the definitions of the range for the chart. However I do have another chart on the dashboard sheet with the exact same set up (just with two lines on the chart), and there I have no problem.
I've tried changing the location of the range definitions but it doesn't seems to work.
Note: these are dynamic ranges.
Here's my code:
Public Sub CreateDailyScoreChart()
Dim WS As Worksheet
Dim WS2 As Worksheet
Dim Rng1 As Range
Dim Rng2 As Range
Dim myValue As Variant
Dim LastRow As Long
Dim FirstRow As Long
Application.ScreenUpdating = False
Set WS = ThisWorkbook.Sheets("Daily Score")
Set WS2 = ThisWorkbook.Sheets("Dashboard")
With WS
'set last row for entire table in order to define range
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
Set Rng1 = .Range("A3:A" & LastRow)
Set Rng2 = .Range("C3:C" & LastRow)
End With
'Input UserID
myValue = InputBox("Insert UserID")
'Filter based on UserID, for this month decending
Sheets("Daily Score").Activate
On Error Resume Next
ActiveSheet.ShowAllData
Rng1.CurrentRegion.AutoFilter Field:=1, Criteria1:="=" & myValue
On Error GoTo 0
With WS.AutoFilter.Sort
.SortFields.Clear
.SortFields.Add2 Key _
:=Rng2, SortOn:=xlSortOnValues, Order:=xlAscending, _
DataOption:=xlSortNormal
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Rng2.AutoFilter Field:=3, Criteria1:=13, _
Operator:=11, Criteria2:=0, SubField:=0
With WS
FirstRow = .AutoFilter.Range.Offset(1).SpecialCells(xlCellTypeVisible).Row
'reset last row for filtered table
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
End With
'Delete existing chart if it exists
On Error Resume Next
With WS2
.ChartObjects("DailyScore").Activate
.ChartObjects("DailyScore").Delete
End With
On Error GoTo 0
'Add new chart
'ThisWorkbook.Sheets("Dashboard").Shapes.AddChart2(322, xlLineMarkers).Select
WS.Activate
WS.Shapes.AddChart2(332, xlLineMarkers).Select
Dim Chart As Chart
Set Chart = ActiveChart
'Defining X and Y Axis values
Dim xRng As Range
Dim vRng1 As Range
With WS
Set xRng = .Range(.Cells(FirstRow, 3), .Cells(LastRow, 3))
Set vRng1 = .Range(.Cells(FirstRow, 2), .Cells(LastRow, 2))
End With
'Adding series 1
Chart.SeriesCollection.NewSeries
Chart.FullSeriesCollection(1).XValues = xRng
Chart.FullSeriesCollection(1).Values = vRng1
Chart.FullSeriesCollection(1).Name = "Score"
Chart.SetElement (msoElementLegendBottom)
Chart.SetElement (msoElementChartTitleAboveChart)
Selection.Caption = "User " & myValue & " Daily Score This Year"
Chart.Parent.Name = "DailyScore"
Chart.ChartArea.Select
Chart.Parent.Cut
Sheets("Dashboard").Select
Sheets("Dashboard").Activate
Range("K20").Select
ActiveSheet.Paste
Application.ScreenUpdating = True
End Sub

Writing this in answer mode to help others:
Following the Set Chart = ActiveChart
add ActiveChart.ChartArea.ClearContents
Chart content should be emptied and chart will come back with desired result after the code completes its run.

Related

When a match is found, copy row from one sheet to the row where the match was found in macro

I have a table on the MainDashboard that is updated by a macro. It copies data from selected sheets and updates this main table. Here is my code but I am stuck. I need it to:
Loop through every sheet in Sheet List
Loop through every value in the first column of the tables on each sheet
Check to see if these IDs are in the first column of the Main Dashboard table
If yes, Copy everything on that row and paste it over the same row where the value was found on the main Dashboard table
If no, add it to the bottom of the row
When finished have a MsgBox that says, you have modified x entries and added x new entries
Sub Update()
Dim SheetList As Variant
Dim x As Long
Dim TaskListTable As Range
Dim TaskList As ListObject
Dim SortColumn As Range
Dim TaskId As Integer
Dim LastRow As Range
Dim MDLastRow As Range
'What I want the Excel program to do before I start
With Application
.ScreenUpdating = False
.StatusBar = "Running..."
End With
'List Sheet Names into an Array Variable
SheetList = Array(S1, S2, S3, S4, S5, S6, S7, S8, S9, S10, S11, S12, S13, S14)
'Loop through list
For x = LBound(SheetList) To UBound(SheetList)
'Code will fail unless you activate the sheet first
SheetList(x).Activate
'Loop for b15 in column 1 down for every row to last row
LastRow = Range("B" & Rows.Count).End(xlUp).Row
MDLastRow = Range("B" & Rows.Count).End(xlUp).Row
For Each TaskID In Range("B15": LastRow)
If WorksheetFunction.Match(Range("B15:MDLastRow"), Then
SheetList(x).Range("TaskID").End(xlRight).Copy
'PASTE TO ENTIRE ROW WHERE THE MATCH WAS FOUND
End If
'Else add row to the bottom
SheetList(x).Range("TaskID").End(xlRight).Copy
MainDashboard.Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteAll
Next x
MainDashboard.Activate
'MsgBox
'You have Modified X tasks
'You have Added X tasks
'Sort the table by the latest Date
Set TaskList = MainDashboard.ListObjects("Task_List")
Set SortColumn = Range("Task_List[DATE]")
With TaskList.Sort
.SortFields.Clear
.SortFields.Add Key:=SortColumn, SortOn:=xlSortOnValues, Order:=xlAscending
.Header = xlYes
.Apply
End With
'What I want the Excel program to do after I have finished
With Application
.ScreenUpdating = True
.StatusBar = "Complete"
.CutCopyMode = False
End With
End Sub
Thanks in advance

Apply greater than logic to already autofiltered rows

I have applied the below filter to an excel sheet which autofilters the column O based on start date and end date.
sht1.Range("$A$1:$X$3432").AutoFilter Field:=15, Criteria1:= _
">=" & CDbl(StartDate), Operator:=xlAnd, Criteria2:="<=" & CDbl(EndDate)
here I have calculated the visible filtered rows based on start date and end date.
With sht1
Total_DCR = WorksheetFunction.Subtotal(102, ActiveSheet.Range("O1:O5000").Columns(1))
Debug.Print Total_DCR
End With
Dim i, delay_count As Integer
Now I want to compare the dates present in filtered column O and X for greater than logic.If O2 >X2 then increment a counter by 1.
For i = 2 To Total_DCR
If sht1.Range("O" & i).Value > sht1.Range("X" & i).Value Then
delay_count = delay_count + 1
Debug.Print delay_count
End If
Next
After executing the above comparison code the count of greater than dates from O column is showing wrong data. I feel it is considering the hidden rows as well. In O column there are 79 dates which are between start date and end date. when I opt for greater than logic between filtered O and X for greater than logic using IF(O2>X2,"YES","NO") logic the greater than rows counts to 53.
I want to implement the same using vba code. But I am getting greater than rows count to 76. I dont know what is wrong here. kindly help
You can get the visible cells without header:
Sub ZZZ()
Dim rng As Range, rngVisible As Range, rngRow As Range, delay_count As Double
Set rng = Range("$A$1:$X$3432")
'// Get visible cells excluding header
With rng
Set rngVisible = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
End With
'// Must use "Cells" when dealing with "Rows" property
For Each rngRow In rngVisible.Rows
delay_count = delay_count + IIf(rngRow.Cells(1, "O") > rngRow.Cells(1, "X"), 1, 0)
Next
End Sub
Private Sub CommandButton1_Click()
Dim F11, F22, Month, Year As Variant
Dim f_name1, f_name2
Dim wb1, wb2, wb3, wb4 As Workbook
Dim sht1, sht2, sht3, sht4 As Worksheet
Dim Total_DCR As Long
Dim StartDate, EndDate As Date
'Select Product Backlog File
F11 = Application.GetOpenFilename("check (*.xlsm*), *.xlsm*")
If (F11 <> vbNullString) Then
If (F11 <> "False") Then
f_name1 = F11
End If
End If
If (f_name1 = "") Then
MsgBox "The check file must be specified."
Exit Sub
End If
Set wb1 = Excel.Workbooks.Open(f_name1)
Set sht1 = wb1.Sheets("Product Backlog")
Set wb3 = ThisWorkbook
Set sht3 = wb3.Sheets("check")
With sht3
StartDate = sht3.Range("J3").Value
'Debug.Print StartDate
If IsDate(StartDate) = True Then
MsgBox ("The following string is a valid date expression")
Else
'if its not a date expression show a message box
MsgBox ("The following string is not a valid date expression")
End If
EndDate = sht3.Range("J4").Value
'Debug.Print EndDate
End With
wb1.Activate
sht1.Activate
sht1.Columns("O:O").Select
wb1.Worksheets("Product Backlog").Sort.SortFields.Clear
wb1.Worksheets("Product Backlog").Sort.SortFields.Add2 Key:=Range( _
"O1"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With wb1.Worksheets("Product Backlog").Sort
.SetRange Range("O1:O3437")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
sht1.Range("$A$1:$X$3432").AutoFilter Field:=15, Criteria1:= _
">=" & CDbl(StartDate), Operator:=xlAnd, Criteria2:="<=" & CDbl(EndDate)
With sht1
Total_DCR = WorksheetFunction.Subtotal(102, ActiveSheet.Range("O1:O5000").Columns(1))
Debug.Print Total_DCR
End With
Dim rng As Range, rngVisible As Range, rngRow As Range, delay_count As Double
Set rng = Range("$A$1:$X$5000")
'// Get visible cells excluding header
With rng
Set rngVisible = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
End With
'// Must use "Cells" when dealing with "Rows" property
For Each rngRow In rngVisible.Rows
delay_count = delay_count + IIf(rngRow.Cells(1, "O") > rngRow.Cells(1, "X"), 1, 0)
Next
MsgBox ("total delay DCR is" & delay_count)
End Sub
#JohnyL this is my whole code. The check work book contains random date from year 2017 to 2020 as per every month in Col O. same way Col X contains date as well. The code must filter them for February 2020 dates and then compare between O and X dates.
start date:01-02-2020
end date:20-02-2020
All the A-X columns have filter dropdown added. when autofilter is applied it will filter the february 2020 dates only. A-X row is there in first row with headers
#EylM Would you mind answering this

cut copy paste looped instruction betwene two sheets

I have had some answers to my question below, but despite numerous attempts I think my code is now just a total mess, and cannot fathom where it is wrong.
So I have a range A12:N112 that needs sorted on row A with descending values.
Next I need to copy each row (B:L) where column A has a "1" in it and paste it into the first blank row in another workbook, based on column D being blank. I then need to copy the number generated in column A for the row I have just pasted into, and then paste this back into the original row I copied in row N of the first spreadsheet.
I need this then to loop until we reach the first value of "0" in the first spreadsheet.
Here is my code, and although I can get the sort to work, I cannot get anything at all to copy or paste. This is similar to code i've used before for a single cut copy paste, but cannot get it to work at all here.
Dim r As Long
Dim lr As Long
Dim wkb As Workbook
Dim ws As Worksheet
Dim wkb2 As Workbook
Dim ws2 As Worksheet
Set wkb = ThisWorkbook
Set ws = wkb.Worksheets("Data Entry")
Set wkb2 = Workbooks.Open("\\srveurfcl03.nov.com\IS-GBR-GLBISETNRegister$\Serial No Trial\Serialisation Log.xlsx")
Set ws2 = wkb2.Worksheets("SNo Log")
wkb.Activate
ws.Activate
ActiveWorkbook.Worksheets("Data Entry").sort.SortFields.Clear
ActiveWorkbook.Worksheets("Data Entry").sort.SortFields.Add Key:=Range( _
"A12:A112"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Data Entry").sort
.SetRange Range("A11:N112")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
For r = 12 To lr
If wkb.ws.Cells(r, 1).Value = 1 Then
ws.Cells(r, "B:L").Copy
wkb2.Activate
ws2.Activate
Range("D" & Rows.Count).EndX(x1Up).Offset(1).Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Range("A" & Rows.Count).End(xlUp).Offset(0).Select
Selection.Copy
wkb.Activate
ws.Cells(r, 13).Value.Paste
End If
If wkb.ws.Cells(r, 1).Value = 0 Then
ws.Cells(4, 9).Select
ActiveCell.FormulaR1C1 = "Serial No. Issue complete for this OA"
End If
Range("F5").Select
Next r
Any help would be greatly appreciated as it always is. I've tried to set variables, but cannot get them to work on bits of my code due to object errors so had to go back to the code I know works. But this only does for fixed ranges, which I will not have in this workbook.
Per my comments, you don't need to sort your data, or use Activate. Using Range("D" & Rows.Count).EndX(x1Up).Offset(1) was going in the right direction except you needed to remove the X in EndX. Also, the portion of code below does not make any sense. So you need to clarify what you want, to include an example of the outcome, if needed.
Range("A" & Rows.Count).End(xlUp).Offset(1).Select
ActiveSheet.Paste
Range("A" & Rows.Count).End(xlUp).Offset(0).Select
Selection.Copy
wkb.Activate
ws.Cells(r, 13).Value.Paste
End If
If wkb.ws.Cells(r, 1).Value = 0 Then
ws.Cells(4, 9).Select
ActiveCell.FormulaR1C1 = "Serial No. Issue complete for this OA"
End If
Range("F5").Select
The best way to copy a range is to copy the complete range, not line-by-line. The code below will hide any rows from Range("A12:A112") that do not have a "1" in column A. It will then copy the visible cells in the range using SpecialCells(xlCellTypeVisible) and paste to the first empty cell in ws2.Column(4). It then makes all the rows that were hidden visible again. This code will work if your workbook and worksheet variables are correct.
Dim ws As Worksheet
Dim wkb2 As Workbook
Dim ws2 As Worksheet
Dim Rng As Range
Set ws = ThisWorkbook.Worksheets("Data Entry")
Set wkb2 = Workbooks.Open("\\srveurfcl03.nov.com\IS-GBR-GLBISETNRegister$\Serial No Trial\Serialisation Log.xlsx")
Set ws2 = wkb2.Worksheets("SNo Log")
For Each cell In ws.Range("A12:A112")
If cell.Value <> "1" Then
cell.EntireRow.Hidden = True
End If
Next cell
Set Rng = ws.Range("A12:A112").SpecialCells(xlCellTypeVisible)
Rng.Copy Destination:=ws2.Cells(Rows.Count, 4).End(xlUp).Offset(1)
ws.Range("A12:A112").EntireRow.Hidden = False

Using VBA to filter a table and copy certain columns to a new sheet

I have a table Named "Combined" which is stored on one sheet of a work book.
On a second sheet I have the following Cell Range (in C1:F2)
Delivery | Column Ref | Column Ref | Available
Delivery ID | I | J | YES
I want to be able to use VBA to filter the table based on the values in this cell range
The Data drop column is a cell with a drop down list which uses VLOOKUP to populate the two column ref cells. These are the two columns that need to be filtered.
Column I needs to show all rows that <>"X" while column J needs to show all rows that equal the value in the available column.
I then need to be able to copy columns A,G and the column that appears in the first reference cell to cell A5 in the second sheet.
Is it possible to do this using VBA? I have been attempting to do this using IF statements, but it is very messy.
I have a piece of code I am attempting to modify from here
Sub Sample()
Dim ws As Worksheet, wsTemp As Worksheet
Dim rRange As Range, rngToCopy As Range
Dim lRow As Long
Dim lRow2 As Long
Dim lCol As Long
'Find the last non-blank cell in column A(1)
lRow2 = Cells(Rows.Count, 1).End(xlUp).Row
'~~> Change this to the relevant sheet
Set ws = ThisWorkbook.Sheets("Combined")
With ws
'~~> Set your range for autofilter
Set rRange = .Range("A1:AR" & lRow2)
'~~> Remove any filters
.AutoFilterMode = False
'~~> Filter, copy visible rows to temp sheet
With rRange
.AutoFilter Field:=9, Criteria1:="X"
'~~> This is required to get the visible range
ws.Rows("1:lRow2").EntireRow.Hidden = True
Set rngToCopy = .SpecialCells(xlCellTypeVisible).EntireRow
Set wsTemp = Sheets.Add
rngToCopy.Copy wsTemp.Range("A1")
'~~> Unhide the rows
ws.Rows("1:lRow").EntireRow.Hidden = False
End With
'~~> Remove any filters
.AutoFilterMode = False
End With
Application.DisplayAlerts = False
wsTemp.Delete
Application.DisplayAlerts = True
End Sub
But I do not know how to modify the With rRange section to meet my needs (i.e, Column I <>"X" and column J=F2
Additionally this line ws.Rows("1:lRow2").EntireRow.Hidden = True is giving me a type mismatch error
example of combined table
UPDATE
So my code now looks like this thanks to this thread
Sub AddFilter()
'
' AddFilter Macro
'
Dim rCrit1 As Range, rCrit2 As Range, rCrit3 As Range
Dim copyRange1 As Range, copyRange2 As Range, copyRange3 As Range
Dim filterRange As Range
Dim lastRow As Long
Set src = ThisWorkbook.Sheets("Combined")
Set tgt = ThisWorkbook.Sheets("Dashboard")
lastRow = src.Range("A" & src.Rows.Count).End(xlUp).Row
Set filterRange = src.Range("A1:Z" & lastRow)
Set copyRange1 = src.Range("A2:A" & lastRow)
Set copyRange2 = src.Range("G2:G" & lastRow)
Set copyRange3 = src.Range("I2:I" & lastRow)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set rCrit1 = Worksheets("Dashboard").Range("Ref_1")
Set rCrit2 = Worksheets("Dashboard").Range("Ref_2")
Set rCrit3 = Worksheets("Dashboard").Range("Ref_3")
Sheets("Dashboard").Range("A1:C3").ClearContents
Sheets("Dashboard").Range("A1:C3").ClearFormats
Selection.AutoFilter
filterRange.AutoFilter Field:=rCrit1, Criteria1:="<>X"
filterRange.AutoFilter Field:=rCrit2, Criteria1:=rCrit_3
copyRange1.SpecialCells(xlCellTypeVisible).Copy tgt.Range("A5")
copyRange2.SpecialCells(xlCellTypeVisible).Copy tgt.Range("B5")
copyRange3.SpecialCells(xlCellTypeVisible).Copy tgt.Range("C5")
End Sub
However the filterRange.Autofilter line is not reading the rCrit_3 value correctly and so is not filtering based on this (Ref_3 is a named range which contains the YES cell in the first part of the problem).
Additionally the copyRange lines are giving me '1004' runtime error, but if I minimise the spreadsheet and run the code from the VBA window, it will run error free.
Can anyone shed some light on these issues?

VBA program sub error; trying to set up conditional loop

This program is intended to be used to copy data from a pivot table on another sheet (varying number of rows for each data set). Each set of pasted data is used to create its own waterfall chart, for which I have templates already made on a different sheet.
There are a couple of issues I am having with this code.
1) For some reason, it no longer runs (I refactored the code from a macro) and gives me the error 'Compile Error: Sub or Function not defined'
- I've tried making a new module and a new macro but to no avail
2) Also, I want to change the range that the chart graphs based on the size of the data set. Here's what I have currently hardcoded:
Selection.Formula = "=SERIES(,Sheet5!R8C1:R17C1,Sheet5!R8C4:R17C4,1)"
So, Sheet5!R8C1:R17C1 would need to become SheetN!Start:End
Complete Code below:
Sub WF_New_Sheet()
Dim copyFrom As Range
Dim wS As Worksheet 'use as current worksheet
Dim cht As Chart
'Paste and format data
Set wS = Sheets("Pivot 1")
copyFrom = wSRange("C82:D90")
Set wS = Sheets.Add(After:=Worksheets.Count)
wS.Range("A9").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False
Selection.Columns.AutoFit
Application.CutCopyMode = False
Range("A9", Range("B" & Rows.Count).End(xlUp).Address).sort Key1:=[b9], _
Order1:=xlAscending, Header:=xlNo 'sorts in 2 lines
Range("A8").Value = "Total"
Range("B8").Value = "=SUM(R[1]C:R[9]C)"
Dim rNum As Integer: rNum = Range("A9", Range("B" & Rows.Count).End(xlUp).Address).Rows.Count
'Paste data template and chart
copyFrom = Sheets("Sheet4").Range("D2:G15") 'sheet 4 is hardcoded and contains templates
wS.Range("D6").Resize(copyFrom.Rows.Count).Value = copyFrom.Value
Sheets("Sheet4").ChartObjects("Chart 1").Activate
Application.CutCopyMode = False
ActiveChart.ChartArea.Copy
wS.Range("I7").Select
ActiveSheet.Paste
ActiveSheet.ChartObjects("Chart 1").Activate
'Set appropriate ranges for chart data; format data for display
ActiveChart.SeriesCollection(2).Select
Selection.Formula = "=SERIES(,Sheet5!R8C1:R17C1,Sheet5!R8C5:R17C5,2)" 'How to make this dynamic?
ActiveChart.SeriesCollection(1).Select
Selection.Formula = "=SERIES(,Sheet5!R8C1:R17C1,Sheet5!R8C4:R17C4,1)" 'How to make this dynamic?
Range("B8").Value = "=SUM(R[1]C:R[9]C)*-1"
With Range("b9", "b17")
.Value = Evaluate(.Address & "*" & -1)
End With
End Sub
*edit code fixed to include sub and end sub
Figured out how to adjust the chart size. Added these lines:
Dim rowStart As Integer: rowStart = InputBox("Please enter starting row of your dataset.")
Dim rowEnd As Integer: rowEnd = InputBox("Please enter ending row of your dataset.")
Set copyFrom = Sheets("Pivot 1").Range(Sheets("Pivot 1").Cells(rowStart, colOne), Sheets("Pivot 1").Cells(rowEnd, colOne))
Set wS = Sheets.Add
wS.Move After:=Sheets(ActiveWorkbook.Sheets.Count)
wS.Range("A9").Resize(copyFrom.Rows.Count, copyFrom.Columns.Count).Value = copyFrom.Value
Set copyFrom = Sheets("Pivot 1").Range(Sheets("Pivot 1").Cells(rowStart, colTwo), Sheets("Pivot 1").Cells(rowEnd, colTwo))
wS.Range("B9").Resize(copyFrom.Rows.Count, copyFrom.Columns.Count).Value = copyFrom.Value

Resources