简体   繁体   中英

Copy cell from one sheet to another, repeat for all cells within range

I need to repeat the code below for cells in the range A2 to A46 that contain values.

Worksheets("Full Qual").Range("A2").Copy _
  Destination:=Worksheets("Test").Range("D4")
ActiveWorkbook.PrintOut From:=2, To:=4, Copies:=1, Collate:=True, _
    IgnorePrintAreas:=False

The goal is to copy the cell from worksheet "Full Qual" to worksheet "Test", print it, then move on to the next cell below and repeat for all cells with values up to cell A46.

Consider:

Dim N As Long, v As Range
For N = 2 To 46
    Set v = Worksheets("Full Qual").Range("A" & N)
    If v.Value <> "" Then
        Worksheets("Full Qual").Range("A" & N).Copy _
          Destination:=Worksheets("Test").Range("D4")
        ActiveWorkbook.PrintOut From:=2, to:=4, Copies:=1, Collate:=True, _
            IgnorePrintAreas:=False
    End If
Next N

UNTESTED

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM