Last row FillDown, Second last row paste special values

Wilfried_1983

New Member
Joined
Jul 17, 2008
Messages
15
Hello,

I have a worksheet that contains cells with VLookup formulas, however I need the actual values of the cells to be used by other formulas in the same worksheet. I decided to use FillDown to drag all formulas (including the Vlookup formulas) one line below and after that copy and special paste the values of the second last row so the values can be used by other formulas.

Below is the code I have produced. It is very redundant in my opinion but I don´t know how to improve it and make it work in the first place.. Any suggestions?

Code:
Sub test()
'
' test Macro
'
Dim LR1 As Long, LR2 As Long, SLR As Long
LR1 = Sheets("Emissões e Recebimentos").Range("B" & Rows.Count).End(xlUp).Row
SLR1 = .Range("B" & Rows.Count - 1).End(xlUp).Row
SLR2 = .Range("D" & Rows.Count - 1).End(xlUp).Row
SLR3 = .Range("F" & Rows.Count - 1).End(xlUp).Row
SLR4 = .Range("I" & Rows.Count - 1).End(xlUp).Row
SLR5 = .Range("J" & Rows.Count - 1).End(xlUp).Row
With Sheets("Emissões e Recebimentos")
    LR2 = .Range("B" & Rows.Count).End(xlUp).Row
    .Range("B" & LR2 & ":W" & LR2).FillDown
    End With
SLR1.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
SLR2.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
SLR3.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
SLR4.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
SLR5.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
        
End Sub

Thanks in advance for your help
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,223,237
Messages
6,170,928
Members
452,366
Latest member
TePunaBloke

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