Hello,
I'm looking for suggestions on the best way to get this routine to loop itself through every sheet after Sheet2.
So, starting with Sheet3 and on, I'm wanting this routine to go through each Sheet and copy the values from the following ranges, ("P6:P"), ("R6:T"), ("V6:V"), and then paste those values in a long consolidated list on Sheet1, or mpl.
Below is the code that currently works as intended for copying values from Sheet3, and pasting to Sheet1.
How do I get "Sheet3" to be replaced with all Sheets 3 and up?
I'm looking for suggestions on the best way to get this routine to loop itself through every sheet after Sheet2.
So, starting with Sheet3 and on, I'm wanting this routine to go through each Sheet and copy the values from the following ranges, ("P6:P"), ("R6:T"), ("V6:V"), and then paste those values in a long consolidated list on Sheet1, or mpl.
Below is the code that currently works as intended for copying values from Sheet3, and pasting to Sheet1.
How do I get "Sheet3" to be replaced with all Sheets 3 and up?
VBA Code:
Sub loop_thru_sheet3_up()
Dim LmbrPrd As Long, LmbrDim, LmbrLen
Dim LmbrPrdPst As Range, LmbrDimPst, LmbrLenPst
Dim LastRow As Integer
Dim mpl As Worksheet
Set mpl = Worksheets("Master Pricing List")
With mpl
If Application.WorksheetFunction.CountA(.Cells) <> 0 Then
LastRow = .Cells.Find(What:="*", After:=.Range("A1"), _
Lookat:=xlPart, LookIn:=xlFormulas, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious, _
MatchCase:=False).Row + 1
Else
LastRow = 1
End If
Set LmbrPrdPst = mpl.Range("A" & LastRow)
Set LmbrDimPst = mpl.Range("B" & LastRow)
Set LmbrLenPst = mpl.Range("E" & LastRow)
LmbrPrd = Sheet3.Range("P300").End(xlUp).Row
Sheet3.Range("P6:P" & LmbrPrd).Copy
LmbrPrdPst.PasteSpecial xlPasteValues
LmbrDim = Sheet3.Range("P300").End(xlUp).Row
Sheet3.Range("R6:T" & LmbrDim).Copy
LmbrDimPst.PasteSpecial xlPasteValues
LmbrLen = Sheet3.Range("P300").End(xlUp).Row
Sheet3.Range("V6:V" & LmbrLen).Copy
LmbrLenPst.PasteSpecial xlPasteValues
End With
End Sub