追加到下一行excel VBA

时间:2017-12-08 17:24:06

标签: vbscript

希望大家都好。以下程序工作正常我只想将我的标签附加到下一行,没有任何限制。任何人都可以帮助我,我会很满意。

Sub ExportExcel(ByVal Atai)

  Dim a
  Set a = CreateObject("Excel.Application")

  a.Visible = True
  a.Workbooks.Open "C:\Users\Muhammad Awais\Desktop\start and stop data logging\POWER METER 1.xls"

  **
  **a.Sheets("raw data").Cells(3, 4).Value = SmartTags("l1-l2")
  a.Sheets("raw data").Cells(4, 4).Value = SmartTags("l2-l3")
  ****

  a.ActiveWorkbook.SaveAs "C:\Users\Muhammad Awais\Desktop\start and stop data logging\"&Day(Date)& ("_") &Month(Date)& ("_") &Year(Date)& ("_") &Hour(Time)&Minute(Time)&".xls"

  a.Workbooks.Close

  a.Quit

  Set a = Nothing
End Sub

1 个答案:

答案 0 :(得分:0)

LastRow = sh.Cells.Find(What:="*", _
                        After:=a.Sheets("raw data").Range("A1"), _
                        Lookat:=xlPart, _
                        LookIn:=xlFormulas, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlPrevious, _
                        MatchCase:=False).Row