我想問一個問題。 我寫了一個簡單的代碼,點擊保存按鈕,然後保存爲「C:\ new folder \」中的excel文件。現在我遇到的問題是如果我在原始Excel表格中添加新行,如何將原始Excel表格的最後一行保存在「C:\ new folder \」中。 我想要保存的表格只包含一行,從原來的Excel表格。如何在excel vb中只保存最後一行excel數據?
Sub Increment()
Range("A1").Value = Range("A1").Value + 1
End Sub
Private Sub CommandButton1_Click()
Dim Path As String
Dim FileNane1 As String
Dim FileName2 As String
Path = "C:\new folder\"
Call Increment
FileNane1 = Range("A1").Value
FileName2 = Range("B1")
ActiveWorkbook.SaveAs Filename:=Path & FileNane1 & "-" & FileName2 & ".xls"
End Sub
上面將整個excel表格保存在「C:\ new folder \」中,我只需要最後一行。
我該如何解決這個問題?
創建新的書,拉最後一行從源代碼的書,保存新書。 – findwindow