Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50158

subscript out of range when trying to select a sheet.

$
0
0
Hi can someone help me, in the below lines im getting an error on the Sheets("TempLRS").Select.... this row brings up a subscript out of range error.

in column A there will be a choice of 5 different values 629,631,646,647 and 650, and there are tabs names the same, what im trying to do is look at the cell take the value and then open that tab, the TempLRS seems to be getting the right value so not to sure why is not working.

Code:

With ActiveSheet

LoadSheetLR = Range("d" & Rows.Count).End(xlUp).Row

    For Counter = LoadSheetLR To 2 Step -1
        With Cells(Counter, "A")
            TempLRS = Cells(Counter, "A").Value
                .EntireRow.Select
                Selection.Cut
                Sheets("TempLRS").Select
                    With ActiveSheet
                        DstLR = .Range("A" & Rows.Count).End(xlUp).Row
                        ActiveSheet.Range("A" & DstLR).Select
                        ActiveSheet.Paste
                        Selection.Copy
                        Selection.PasteSpecial Paste:=xlPasteAll
                        Application.CutCopyMode = False
                        Sheets("LoadSheet").Select
                    End With
        End With
    Next Counter


Viewing all articles
Browse latest Browse all 50158

Trending Articles