【问题标题】:VBA to dum Data to specific Cell in a different Sheet in the same WorkbookVBA将数据转储到同一工作簿中不同工作表中的特定单元格
【发布时间】:2022-11-14 12:15:31
【问题描述】:

我正在寻找一个 VBA 脚本来将表格中的数据写入工作表中的指定单元格。

例如:在图像表中 - 第 1 列是序列号,第 2 列是要写入的数据,第 3 列是应该写入的工作表,第 4 列是相应工作表中的单元格。

我正在寻找一个 VBA 脚本来将第 1 行和第 2 列中的“1”写入工作表“A”中的单元格“A1”。

【问题讨论】:

    标签: excel vba excel-formula macros


    【解决方案1】:

    这是它的代码:

    Sub Dump2Print()
    LastRow = Cells(Rows.Count, "A").End(xlUp).Row
    Dim rng As Range: Set rng = Application.Range("Dump!A1:A" & LastRow)
    Dim i As Integer
    Set wb = ActiveWorkbook
    For i = 1 To rng.Rows.Count
        MyValue = rng.Cells(RowIndex:=i, ColumnIndex:="B").Value       
        MySheet = rng.Cells(RowIndex:=i, ColumnIndex:="C").Value       
        MyRange = rng.Cells(RowIndex:=i, ColumnIndex:="D").Value       
        Set ws = wb.Sheets(MySheet)       
        ws.Activate       
        ws.Range(MyRange) = MyValue
    Next
    End Sub
    

    此代码将查看名为“Dump”的工作表中表中的所有数据,并从“B”、“C”和“D”列中读取值。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-13
      • 2013-12-30
      • 1970-01-01
      • 2014-11-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多