When finished "looping", select first cell in range

Gerasimos_Zap

New Member
Joined
Sep 23, 2015
Messages
20
I have a script that loops through sections on one sheet (Function Test Procedure) and pastes those values into another sheet (Results) in cell L2. The way it is currently set up is to loop for the number of sections, copy and paste those values to the Results sheet and select the next empty cell in column L. That works just fine, as long as the button is not pressed multiple times. When the button is pressed multiple times, it will add the copied results under the results that were already there. What I want to do is modify the script to loop through the available sections and then select cell L2 to paste the updated results over the existing results if the button is pressed numerous times. This should be simple, but I cannot figure it out.


Code:
    Sub Copy_ATP_Tables()


     Dim SectionATP As Long, NextRow As Long
    
      For SectionATP = 1 To 35 '36
        
        NextRow = Sheets("Results").Range("L" & Rows.Count).End(xlUp).Row + 1 'Next empty row
        
        Sheets("Acceptance Test Procedure").Range("APTSec" & SectionATP).Columns("A:H").Copy _
        Destination:=Sheets("Results").Range("L" & NextRow) 'SpecialCells(xlCellTypeVisible)
            
    '        Range("FTPSec" & Section).Columns("G:H").SpecialCells(xlCellTypeVisible).Copy _
    '            Destination:=Sheets("Results").Range("N" & NextRow)
    
      Next SectionATP


    '    Sheets("Results").Range("ATPResults").Select
    '    For SectionATP = 35 To 35


    End Sub
 
Add a line to clear column L before the loop is initiated.

Code:
Sheets("Results").Range("L:L").ClearContents
 
Upvote 0
That worked perfectly. The production people will love that (they like pressing buttons multiple times to make sure it worked). Thank you for your help!
 
Upvote 0
That worked perfectly. The production people will love that (they like pressing buttons multiple times to make sure it worked). Thank you for your help!
You are welcome - thanks for the reply.
 
Upvote 0

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