I have the following VBA code which works except part bolded. Basically I want the "control" sheet to summarise the data from the other sheets - the item specified in cell B7, the name of the sheet, the values from N7:Q7. The cells N7:Q7 are formula but I want the values calculated to be pasted into the control sheet. Appreciate any help.
Sub next1()
Sheets("Control").Select
ActiveSheet.Unprotect
Sheets("Control").Range("B7:C36").ClearContents
Dim oCell As Range
Dim ws As Worksheet
Set oCell = ThisWorkbook.Worksheets("Control").Range("C7")
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Control" And ws.Name <> "First" And ws.Name <> "End" And ws.Name <> "Loan" And ws.Name <> "NewSheet" Then
oCell.Value = ws.Name
oCell.Hyperlinks.Add Anchor:=oCell, Address:="", SubAddress:=ws.Name & "!A1"
Set oCell = oCell.Offset(1, 0)
End If
Next ws
Range("B7").Select
Dim bCell As Range
Dim wt As Worksheet
Set bCell = ThisWorkbook.Worksheets("Control").Range("B7")
For Each wt In ThisWorkbook.Worksheets
If wt.Name <> "Control" And wt.Name <> "First" And wt.Name <> "End" And wt.Name <> "Loan" And wt.Name <> "NewSheet" Then
bCell.Value = Range("B7").Value
bCell.Hyperlinks.Add Anchor:=bCell, Address:="", SubAddress:=wt.Name & "!B7", TextToDisplay:=wt.Range("B7").Value
Set bCell = bCell.Offset(1, 0)
End If
Next wt
Range("B7").Select
Dim LR As Long
LR = Range("B7").End(xlDown).Row
Range("B7").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Control").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Control").Sort.SortFields.Add Key:=Range("B7"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Control").Sort
.SetRange Range("B7:C36")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D7:G36").Select
Selection.ClearContents
Range("D7").Select
Dim gCell As Range
Dim wa As Worksheet
Set gCell = ThisWorkbook.Worksheets("Control").Range("D7")
For Each wa In Worksheets
If wa.Name <> "Control" And wa.Name <> "First" And wa.Name <> "End" And wa.Name <> "Loan" And wa.Name <> "NewSheet" Then
wa.Range("N7:Q7").Copy
ActiveSheet.PasteSpecial xlPasteValues
Set gCell = gCell.Offset(1, 0)
End If
Next wa
Range("B7:C36").Select
Selection.Locked = False
Selection.FormulaHidden = False
Sheets("Control").Select
Range("D7").Select
ActiveSheet.Protect
ActiveWorkbook.Protect
End Sub
Sub next1()
Sheets("Control").Select
ActiveSheet.Unprotect
Sheets("Control").Range("B7:C36").ClearContents
Dim oCell As Range
Dim ws As Worksheet
Set oCell = ThisWorkbook.Worksheets("Control").Range("C7")
For Each ws In ThisWorkbook.Worksheets
If ws.Name <> "Control" And ws.Name <> "First" And ws.Name <> "End" And ws.Name <> "Loan" And ws.Name <> "NewSheet" Then
oCell.Value = ws.Name
oCell.Hyperlinks.Add Anchor:=oCell, Address:="", SubAddress:=ws.Name & "!A1"
Set oCell = oCell.Offset(1, 0)
End If
Next ws
Range("B7").Select
Dim bCell As Range
Dim wt As Worksheet
Set bCell = ThisWorkbook.Worksheets("Control").Range("B7")
For Each wt In ThisWorkbook.Worksheets
If wt.Name <> "Control" And wt.Name <> "First" And wt.Name <> "End" And wt.Name <> "Loan" And wt.Name <> "NewSheet" Then
bCell.Value = Range("B7").Value
bCell.Hyperlinks.Add Anchor:=bCell, Address:="", SubAddress:=wt.Name & "!B7", TextToDisplay:=wt.Range("B7").Value
Set bCell = bCell.Offset(1, 0)
End If
Next wt
Range("B7").Select
Dim LR As Long
LR = Range("B7").End(xlDown).Row
Range("B7").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Control").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Control").Sort.SortFields.Add Key:=Range("B7"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Control").Sort
.SetRange Range("B7:C36")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("D7:G36").Select
Selection.ClearContents
Range("D7").Select
Dim gCell As Range
Dim wa As Worksheet
Set gCell = ThisWorkbook.Worksheets("Control").Range("D7")
For Each wa In Worksheets
If wa.Name <> "Control" And wa.Name <> "First" And wa.Name <> "End" And wa.Name <> "Loan" And wa.Name <> "NewSheet" Then
wa.Range("N7:Q7").Copy
ActiveSheet.PasteSpecial xlPasteValues
Set gCell = gCell.Offset(1, 0)
End If
Next wa
Range("B7:C36").Select
Selection.Locked = False
Selection.FormulaHidden = False
Sheets("Control").Select
Range("D7").Select
ActiveSheet.Protect
ActiveWorkbook.Protect
End Sub