|
楼主 |
发表于 2018-9-18 22:04
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Function AddressRng(TabRng As Range, Rng As Range, SheetRng As Range, FormulaRng As Range)
Dim Arr, Ccc
Ccc = 1
Dim oRng As Range, oRng1 As Range
Dim Rng1 As Range, Rng2 As Range, Rng3 As Range
Dim Rr1 As Range, Rr2 As Range, Rr3 As Range
Dim Sht As Worksheet, Sht1 As Worksheet
Set Sht = Rng.Parent
Set Sht1 = SheetRng.Parent
''
Arr = AreaRetuArr(Sht.Range(Rng.Formula))
For ii = 0 To UBound(Arr)
With Sht
Set Rng1 = .Range(Arr(ii, 1))
Set Rng2 = .Range(Arr(ii, 0))
'Debug.Print Rng1.Address, Rng2.Address
'Set Rng3 = Rng2(, 4)
Set Rr1 = .Range(Rng2(, 4).Formula)
'Set Rng3 = Rr1.Areas(3)
With Sht1
Set Rr1 = .Range(Rr1.Areas(3).Address).Resize(Rr1.Areas(2).Rows.Count, 1)
'Set Rr1 = Rr1(2, 1).Resize(Rr1.Rows.Count - 1, 1)
Set Rr2 = Rr1(, "H").Resize(Rr1.Rows.Count, 2)
'Debug.Print Rr1.Address, Rr2.Address, Rr2(, 1), Rr2(, 2), TabRng.Address
End With
''
For jj = 1 To Rng2
SheetRng(0, Ccc) = "$CONFIGURATION@" & Rng1 & "<" & jj & ">"
SheetRng(0, Ccc + 1) = "$STATE@" & Rng1 & "<" & jj & ">"
SheetRng(, Ccc + 1) = "S"
SheetRng(, Ccc) = "=" & Rr1(, 1).Address '(0, 0)
Set oRng = SheetRng(, Ccc).Resize(TabRng.Rows.Count, 2)
oRng.FillDown
DNTHKAssoConf Sht1, SheetRng(, Ccc), TabRng, Rr2
'Debug.Print TabRng.Address, Rr1.Address, Rr2.Address
''
With SheetRng(, Ccc)
.Font.Size = 10
'.Orientation = 90
'.Interior.ColorIndex = 40
End With
Ccc = Ccc + 2
Next jj
End With
Next ii
''
Set oRng = SheetRng(0, 1).Resize(, Ccc - 1)
With oRng
.Font.Size = 10
.Orientation = 90
.Interior.ColorIndex = 6
Set Sht = .Parent
End With
With Sht
Set oRng1 = .Range(FormulaRng.Formula)
Set oRng = .Range(.Cells(oRng1.Row, 1), .Cells(oRng1.Row + oRng1.Rows.Count - 1, oRng.Column + oRng.Columns.Count - 1))
End With
FormulaRng = "=" & oRng.Address(0, 0)
End Function |
|