循环与跳过行 [英] Loop with skipping rows

查看:71
本文介绍了循环与跳过行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单独的工作表,我正在尝试创建一个复制和粘贴循环。

I have two separate worksheet ands I am trying to create a copy and paste loop.

我需要复制每个列中的第7个单元格(列G从单元格28开始然后35,41等直到单元格77.

I need to copy every 7th cell in a column (column G starting in cell 28 then 35, 41 etc. up until cell 77.

然后我需要将这些单元格粘贴到另一个工作表中的P列中,从单元格111并在单元格118中完成(这些需要直接粘贴在彼此之下,没有空格)

I then need to paste these cells into column P in another worksheet, starting in cell 111 and finishing in cell 118 (these need to be pasted directly below one another with no spaces)

到目前为止,我有这段代码但是它似乎只复制第一张工作表中的一个单元格。 

So far I have this code but it seems to be copying only one cell from the first worksheet. 

Sub Looptest()



Sheets("Conservadora")。选择



Dim X As Integer,Y As Integer



  对于X = 111到118

     对于Y = 28到80步骤7

      范围(" P"& X).Value = Sheets(" ; PATRIMONIO")响了。 E(" G" &安培; Y).Value



   下一个Y,X左右


结束分子




Sub Looptest()

Sheets("Conservadora").Select

Dim X As Integer, Y As Integer

   For X = 111 To 118
        For Y = 28 To 80 Step 7
           Range("P" & X).Value = Sheets("PATRIMONIO").Range("G" & Y).Value

    Next Y, X

End Sub


任何帮助都会非常感激。

any help would be really appreciated.

推荐答案

I不要认为你需要放2个for循环:

I don't think you need to put 2 for loops:


这篇关于循环与跳过行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆