VBA - Copy last line in area, paste 1 line below, delete formula in above specific row leaving number

MSchädler

Board Regular
Joined
Apr 27, 2017
Messages
95
Hi, I'm racking my brain over this task and maybe someone can help me to find the proper vba-macro to execute this.
Thanks for any help.

Situation.
In row I to N and lines 19 to 36 I input monthly specific numbers. This is my range (I to N, 19 to 36)

Task:
1. I would like a VBA-macro which finds my last line with numbers in that range (I to N), copies that line and paste it into next line below.
2. After that I want to erase the formulae in the above line in row L and replace it with just the number.

Thanks for any help !
 

Attachments

  • Excel.JPG
    Excel.JPG
    125.3 KB · Views: 10

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Oh yeah, this is my macro so far and it doesn't work.

Public Sub COPY_MAKRO()
Dim i As Integer
For i = 8 To 13
letzteZeile = ActiveSheet.Cells(Rows.Count, i).End(xlUp).Offset(0, 1).Select
Selection.Copy
With ActiveCell
Range(.Offset(0, 1), .Offset(0, 5)).Select
End With
ActiveSheet.Paste
Next i
End Sub
 
Upvote 0
Hi

So i probably do not follow exaclly what you want, but please see below.

This finds last row of data in column I
then copies that row to the row below and changes the existing row to values.

VBA Code:
Sub db()
    lr = Range("i" & Rows.Count).End(xlUp).Row
    Range(Cells(lr, 9), Cells(lr, 14)).Copy
    Cells(lr, 9).PasteSpecial xlValues
    Cells(lr + 1, 9).PasteSpecial xlValues
End Sub
 
Upvote 0
Hi

So i probably do not follow exaclly what you want, but please see below.

This finds last row of data in column I
then copies that row to the row below and changes the existing row to values.

VBA Code:
Sub db()
    lr = Range("i" & Rows.Count).End(xlUp).Row
    Range(Cells(lr, 9), Cells(lr, 14)).Copy
    Cells(lr, 9).PasteSpecial xlValues
    Cells(lr + 1, 9).PasteSpecial xlValues
End Sub
Hello Squidd

Thank you for your quick help. Your VBA works well. Now I have to further expand it to fit my needs.

Thanks again
 
Upvote 0
Hello Squidd

Thank you for your quick help. Your VBA works well. Now I have to further expand it to fit my needs.

Thanks again
Hello Squidd
Can you help me with the following problem:
I have used your VBA in my excel sheet and the main task works well. I thought I could now refine that VBA but I'm coming to my limits.
This is the adapted VBA:

Sub START()
lr = Range("i" & Rows.Count).End(xlUp).Row ' find last row of data
Range(Cells(lr, 9), Cells(lr, 14)).Copy ' copy the last row

Cells(lr + 1, 9).PasteSpecial xlFormulas ' paste 1 row below with Formulas


Range(Cells(lr, 11), Cells(lr, 11)).Copy ' copy one cell with formulas HERE I WANT TO COPY SPECIFIC CELL (with formulas) FROM THE PREVIOUS ROW
Cells(lr, 11).PasteSpecial x1Values ' paste into same cell as Value AND PASTE IT AS A VALUE (no formulas)


End Sub

1683586807695.png


Can you help?
Thank you in advance
 
Upvote 0
Hi

Thanks for the feedback, not sure if this is what you wanted, but you should be able to adjust it to suit

VBA Code:
Sub db()
    lr = Range("k" & Rows.Count).End(xlUp).Row 'gets the last row of data in column K
    Range("i" & lr & ":n" & lr).Copy 'copies i to n of said last row
    Range("i" & lr + 1).PasteSpecial xlValues 'pastes the copied range to the row below as values.
    Range("K" & lr).AutoFill Destination:=Range("K" & lr & ":K" & lr + 1), Type:=xlFillDefault 'drags the formula from column k down 1 row from last row
    Range("i" & lr & ":n" & lr).Copy 'copies the lasrow of data again
    Range("i" & lr).PasteSpecial xlValues 'pastes them back to the same range as values
End Sub
 
Upvote 0
Solution
Hi Squidd
thanks again for your help.
That VBA works quite well and does what I was looking for. Now just a bit of tweeking:)
Have a great day
Marc
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,851
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top