I have an excel spreadsheet. There are two sheets in this.
Sheet1:
CompanyDepartmentAddressline1Addressline2
Sheet2:
AccountDepartmentAddress
I need to :
- Check till the last non blank row in 
Companycolumn. - Copy the 
Companydata values intoSheet2.Account,Sheet1.DepartmentintoSheet2.Department. - Concatenate 
Sheet1.Adddressline1andSheet2.Addressline2. - Copy into 
Sheet2.Addresson clicking a button using VBA Macros. 
code:
Sub Button1_click()
 Worksheets("Sheet1").Range("A2").Copy _
    Destination:=Worksheets("Sheet2").Range("F2" & Rows.Count).End(xlUp).Offset(1)
 Worksheets("Sheet1").Range("B2").Copy _
    Destination:=Worksheets("Sheet2").Range("C2" & Rows.Count).End(xlUp).Offset(1)
 Worksheets("Sheet1").Range("F2").Copy _
    Destination:=Worksheets("Sheet2").Range("B2" & Rows.Count).End(xlUp).Offset(1)
  Worksheets("Sheet1").Range("H2").Copy _
    Destination:=Worksheets("Sheet2").Range("K2" & Rows.Count).End(xlUp).Offset(1)
 Worksheets("Sheet1").Range("I2").Copy _
    Destination:=Worksheets("Sheet2").Range("K2:K200" & Rows.Count).End(xlUp).Offset(1)
  Worksheets("Sheet1").Range("L2").Copy _
    Destination:=Worksheets("Sheet2").Range("M2" & Rows.Count).End(xlUp).Offset(1)
Worksheets("Sheet1").Range("AO2").Copy _
    Destination:=Worksheets("Sheet2").Range("I2" & Rows.Count).End(xlUp).Offset(1)
 Worksheets("Sheet1").Range("BF2").Copy _
    Destination:=Worksheets("Sheet2").Range("J2" & Rows.Count).End(xlUp).Offset(1)
End Sub
No comments:
Post a Comment