Hi all i am new to Excel VBA and i need help in coming up with a macro to carry out a time consuming task.
This is what i want the Macro to do when the Update data button is clicked: It should copy the information from certain columns (A,B and F for example) of worksheet 1 and "paste special" this in worksheet 2 and in columns A, B and C.
The tricky part is when pasting this information it should paste the information on every other row and it should not change the format of worksheet 2. At the same time all the figures in column C should move one cell down and have a text in the next row in column B which says "According to the Balance Sheet records". This is how the output should look:
Sheet 1
Column A Column B Column C ...... Column F
1000 Revenue .... 2000
2000 Cost .... 3000
Sheet 2 = Output after Update button is pressed
Column A Column B Column C
1000 Revenue
According to the BS record 2000
empty row empty row empty row
2000 Cost
According to the BS record 3000
In addition to this i will need a button that is able to undo what is copied and another button that adds new rows when a particular cell is selected. For example if i select cell A4 and press the button a new row is inserted in cell A4:AZ4
Thanks a million for helping
This is what i want the Macro to do when the Update data button is clicked: It should copy the information from certain columns (A,B and F for example) of worksheet 1 and "paste special" this in worksheet 2 and in columns A, B and C.
The tricky part is when pasting this information it should paste the information on every other row and it should not change the format of worksheet 2. At the same time all the figures in column C should move one cell down and have a text in the next row in column B which says "According to the Balance Sheet records". This is how the output should look:
Sheet 1
Column A Column B Column C ...... Column F
1000 Revenue .... 2000
2000 Cost .... 3000
Sheet 2 = Output after Update button is pressed
Column A Column B Column C
1000 Revenue
According to the BS record 2000
empty row empty row empty row
2000 Cost
According to the BS record 3000
In addition to this i will need a button that is able to undo what is copied and another button that adds new rows when a particular cell is selected. For example if i select cell A4 and press the button a new row is inserted in cell A4:AZ4
Thanks a million for helping
Code:
Sub Button_update_data()
Dim x As Worksheet, y As Worksheet, LastRow&
'Change the link to where you saved your files
Set x = Worksheets("Fortnoxbalans")
Set y = Worksheets("Test_Avst")
LastRow = x.Cells.SpecialCells([INDENT]<wbr>xlCellTypeLastCell).Row
x.Range("A1:A" & LastRow).Copy y.Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
x.Range("B1:B" & LastRow).Copy y.Cells(Rows.Count, "B").End(xlUp).Offset(1, 0)
x.Range("F1:F" & LastRow).Copy y.Cells(Rows.Count, "C").End(xlUp).Offset(1, 0)
Application.CutCopyMode = False
End Sub
[/INDENT]
Last edited by a moderator: