图表格式妨碍了我的VBA范围

时间:2018-07-16 11:56:06

标签: excel vba excel-vba formatting

我正在尝试在一系列不同的实例中提取数据。我停留在要提取的第一组数据上,因为我相信图表的格式设置会干扰我的数据位置。数据将影响图表。该图表位于范围A1:A23到E1:E23之间。数据从B25:B36到E25:E36开始。数据正在拉到V1。

Sub OneClickAuotFill()
    Dim Row2 As Long
    Dim Row3 As Long
    Dim Row4 As Long
    Dim Row5 As Long

    Row2 = Cells(Rows.Count, 2).End(xlUp).Row + 1
    Row3 = Cells(Rows.Count, 3).End(xlUp).Row + 1
    Row4 = Cells(Rows.Count, 4).End(xlUp).Row + 1
    Row5 = Cells(Rows.Count, 5).End(xlUp).Row + 1

    Dim wb As Workbook, wb2 As Workbook
    Dim ws As Worksheet, works As Worksheet
    Dim vFile As Variant

    Set ws = Sheets("Re-Releases")
    ws.Activate

    Set wb2 = ActiveWorkbook
    ActiveWorkbook.FollowHyperlink "C:\Users\sncook\Desktop\Engineering Charts\On Time Delivery Calc.xlsm"

    Set wb = ActiveWorkbook
    Set works = ActiveSheet

    Dim PageName As Variant
    PageName = InputBox("Please Enter Page Name", "Information")
    ActiveSheet.Name = PageName

    'wb2.Worksheets("Re-Releases").Range("A24").Select
    wb2.Worksheets("Re-Releases").Cells(Row2 & 1).Value = wb.Worksheets(PageName).Range("M324").Value
    wb2.Worksheets("Re-Releases").Range("C" & Row3).Value = wb.Worksheets(PageName).Range("N324").Value
    wb2.Worksheets("Re-Releases").Range("D" & Row2).Formula = "=IFERROR(SUM(1-C:C/B:B), 0)"
    wb2.Worksheets("Re-Releases").Range("E" & Row2).Value = wb.Worksheets(PageName).Range("M324").Value

    wb.Close

    If wb2.Worksheets("Re-Releases").Range("B28") = "" Then
        MsgBox "Didn't Work"
    Else
        MsgBox "Did Work"
    End If
End Sub

0 个答案:

没有答案