将Range对象存储在Variant中

时间:2016-09-11 23:55:45

标签: excel vba excel-vba

Sub test()
    Dim rng As Range
    Dim not_rng As Variant
    Set rng = Sheets("Test").Range("A1:B2")
    Debug.Print TypeName(rng)
    not_rng = rng
    Debug.Print TypeName(not_rng)
End Sub

上面的代码打印

Range
Variant()

我希望打印Range, Variant

1 个答案:

答案 0 :(得分:1)

啊,我错过了NSAttributedString * attributedString = [[NSAttributedString alloc] initWithString:@"Temp String" attributes:@{NSForegroundColorAttributeName:[UIColor redColor]}]; [attributedString enumerateAttribute:NSForegroundColorAttributeName inRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { if (value) { UIColor *color = (UIColor *)value; NSLog(@"Color : %@", color); } }]; 关键字:

Set

现在打印

Sub test()
    Dim rng As Range
    Dim not_rng As Variant
    Set rng = Sheets("Test").Range("A1:B2")
    Debug.Print TypeName(rng)
    Set not_rng = rng
    Debug.Print TypeName(not_rng)
End Sub

这更有意义。