从访问excel导出时打开多个excel工作表

时间:2016-01-29 15:18:42

标签: excel vba excel-vba

我正在尝试为一个工作簿打开多个excel工作表。我有以下代码但它在Sheets上生成错误(" sheet3")。选择行。

我不知道为什么?

Set xlSheet = xlBook.Worksheets(3)

With xlSheet
    .Name = "sheet3"
    ....
    ....
    ....

 i = 6
    Do While Not rsl.EOF
        .Range("A" & i).Value = Nz(rsl!x, "")
        .Range("B" & i).Value = Nz(rsl!y, "")
        .Range("C" & i).Value = Nz(rsl!z, "")
        .Range("D" & i).Value = Nz(rsl!xx, "")
        .Range("E" & i).Value = Nz(rsl!yy, "")
        .Range("F" & i).Value = Nz(rsl!zz, "")
        .Range("G" & i).Value = Nz(rsl!xxx, "")
        .Range("H" & i).Value = Nz(rsl!yyy, "")
        .Range("I" & i).Value = Nz(rsl!zzz, "")           
        i = i + 1
        rsl.MoveNext
    Loop
    End With


With xlSheet
 Set rng = .Range("A6:I5000")
 Sheets("sheet3").Select
 rng.FormatConditions.Add Type:=xlExpression,   Formula1:=""
 rng.FormatConditions(rng.FormatConditions.Count).SetFirstPriority
 With rng.FormatConditions(1).Interior
     .PatternColorIndex = xlAutomatic
    .Color = ANy Color      
 End With


Set rng = .Range("A6:I5000")
Sheets("sheet3").Select
rng.FormatConditions.Add Type:=xlExpression, Formula1:=""
rng.FormatConditions(rng.FormatConditions.Count).SetFirstPriority
With rng.FormatConditions(1).Interior
    .PatternColorIndex = xlAutomatic
    .Color = Any color
    .TintAndShade = 0
End With        

结束

我是否需要更换表格("")。选择其他内容?或者我如何实现它?

谢谢,

0 个答案:

没有答案