In the opened A.XLSX, copy C3 and paste it into the cell in the first column and the last row of B. The procedure is as follows:
Sub macro 1()
Range("C3").Select 'Select C3
Selection.Copy 'Copy
Windows("B.xlsx").Activate 'Select the B.XLSX workbook
lastrow = Cells(Rows.Count, 1).End(3).Row 'Find the last row of the first column
Cells(lastrow, 1).Select 'Select the cells in the last row of the first column
ActiveSheet.Paste 'Paste
cells(1,1)=Cells(lastrow, 3) 'Read the value in the third column of the current row and write it into the first cell of the current xls table
Windows("A.xlsx").Activate 'Return to XLSX
End Sub
Sub Test004()
Dim CoLumn_Num As String
Dim Num As Long
Num = Range("IV1").End(xlToLeft).Column
If Num
CoLumn_Num = Chr(64 Num)
ElseIf Num Mod 26 = 0 Then
CoLumn_Num = Chr(63 Num \ 26) & Chr(90)
Else
CoLumn_Num = Chr(64 Num \ 26) & Chr(64 (Num) Mod 26)
End If
MsgBox "First row and last column:" & CoLumn_Num & "Column"
End Sub
Has been tested, feel free to use
The above is the detailed content of Using VBA, write data to the last row and first column of another Excel file. For more information, please follow other related articles on the PHP Chinese website!