I'm modifying some code which adds links between a Summary Sheet and costing sheets. I'm trying to code the following formula to every CS sheet in cell C1. =CONCATENATE(SUMMARY!L9," - ",SUMMARY!M9," : ",SUMMARY!N9), where the row will change. I'm having trouble with the syntax. What is the easiest way to achieve this?
Code below (which almost works but does not put the required " into the formula
Sub CSrefs()
'
' Adds links from Summary Sheet to CS Sheets: - Updated 29/09/15 PRS
Dim i As Integer, iOffset As Integer, intCount As Integer
Dim intCS1_Index As Integer, intCSCount As Integer, nonCSSheets As Integer
Dim sFormulaText As String, sDash As String, sDots As String
Application.ScreenUpdating = False
intCount = ActiveWorkbook.Sheets.Count 'Find total number of workbook sheets
intCS1_Index = Sheets("CS1").Index 'CS1 Sheet index
intCSCount = intCount - (intCS1_Index - 1) 'Find total number of CS sheets
nonCSSheets = intCount - intCSCount 'Find total number of Non-CS sheets
sDash = " - "
sDots = " : "
For i = 1 To intCSCount 'number of sheets
iOffset = i + 8 'Start of Summary Sheet CS Rows
With Sheets("CS" & i)
sFormulaText = "=CONCATENATE(SUMMARY!L" & iOffset & "," & sDash & ",SUMMARY!M" & iOffset & "," & sDots & ",SUMMARY!N" & iOffset & ")"
' .Range("B1").Formula = sFormulaText
.Range("A1").Hyperlinks.Add Anchor:=.Range("A1"), Address:="", SubAddress:="Summary!D" & iOffset, TextToDisplay:="SUMMARY" 'Go to Summary Sheet hyperlink
.Range("A1").Font.Size = 8
.Range("G1").Formula = "=SUMMARY!O" & iOffset ' UOM
.Range("E1").Formula = "=SUMMARY!P" & iOffset 'SOR Qty
.Range("I1").Formula = "=SUMMARY!R" & iOffset 'Cable Average
' .Range("H10").Formula = "=SUMMARY!C" & iOffset 'Sage Code
.Range("N17").Formula = "=SUMMARY!AC" & iOffset 'Materials GP%
.Range("P17").Formula = "=SUMMARY!AP" & iOffset 'Materials MCD GP%
.Range("N42").Formula = "=SUMMARY!AD" & iOffset 'Misc GP%
.Range("P42").Formula = "=SUMMARY!AP" & iOffset 'Misc MCD GP%
.Range("N67").Formula = "=SUMMARY!AE" & iOffset 'Labour GP
.Range("P67").Formula = "=SUMMARY!AP" & iOffset 'Labour MCD GP%
.Range("N92").Formula = "=SUMMARY!AF" & iOffset '3rd Party GP%
.Range("P92").Formula = "=SUMMARY!AP" & iOffset '3rd Party MCD GP%
.Range("N117").Formula = "=SUMMARY!AG" & iOffset 'PM&PL GP%
.Range("P117").Formula = "=SUMMARY!AP" & iOffset 'PM&PL MCD GP%
.Range("N142").Formula = "=SUMMARY!AH" & iOffset 'Bond GP%
.Range("P142").Formula = "=SUMMARY!AP" & iOffset 'Bond MCD GP%
.Range("N152").Formula = "=SUMMARY!AG" & iOffset 'Support GP%
.Range("P152").Formula = "=SUMMARY!AP" & iOffset 'Support MCD GP%
.Range("N177").Formula = "=SUMMARY!AH" & iOffset 'Day Works GP%
.Range("P177").Formula = "=SUMMARY!AP" & iOffset 'Day Works MCD GP%
End With
Next i
Sheets("Summary").Select
Application.ScreenUpdating = True
End Sub