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?
Thanks in advance for your help
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