I have a range copied in memory.
Next I need to Paste Link it with the rows absolute and columns relative.
I always select manually the Destination Range
- if Destination Range is on a different worksheet font color shall be
blue - if Destination Range is on same worksheet font color shall be
green
The macro bellow sorts out the Paste Link, conversion of formula to rows abs refs and font blue.
I do not know how to tell it to compare the source worksheet with the destination worksheet and apply font color accordingly.
Sub PasteLink_Array_Blue_Green()
Dim rng As Range
Dim arr As Variant
Dim i As Long, j As Long
activeSheet.Paste Link:=True
' Paste the links into the currently active sheet
Set rng = Selection
' Store the selection in a range object
arr = rng.formula
' Convert the formulas to an array
For i = LBound(arr, 1) To UBound(arr, 1)
For j = LBound(arr, 2) To UBound(arr, 2)
If IsArray(arr(i, j)) Then
arr(i, j) = Application.ConvertFormula(arr(i, j)(1, 1), xlA1, xlA1, xlAbsRowRelColumn)
Else
arr(i, j) = Application.ConvertFormula(arr(i, j), xlA1, xlA1, xlAbsRowRelColumn)
End If
Next j
Next i
' Looped through the array and convered each formula
rng.formula = arr
' Apply the converted formulas back to the range
rng.Font.Color = RGB(0, 0, 255)
' Change the font color to blue
End Sub
Your help would be appreciated.