Excel VBA复制粘贴到下一个空列

时间:2018-10-08 12:53:39

标签: excel copy paste

我在D8:E30单元格中有计算和文本。我想创建用于复制D8:E30范围的按钮,使其具有所有填充颜色,边框,公式和文本,并粘贴到下一个空列。在起始点F8是可以复制D8:E30范围的第一个。按下按钮D8:E30复制到F8,然后再次按下按钮D8:E30复制到下一个空列,它将是H8 ...,依此类推。我设法弄出下面的代码,但是它正在插入到下一个空的ROW(非常),我需要它成为下一个空的Column(水平)。有人可以帮忙吗?谢谢!

Sub CopyPaste()
Application.ScreenUpdating = False
Dim copySheet As Worksheet
Dim pasteSheet As Worksheet

Set copySheet = Worksheets("Price calculation")
Set pasteSheet = Worksheets("Price calculation")

copySheet.Range("D8:E30").Copy
pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial xlPasteFormulas

Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

1 个答案:

答案 0 :(得分:1)

这部分代码决定粘贴位置:

Given User is open the browser for Fpl_tc1
And User is type the url for Fpl_tc1
When User is enter the valid username and password and click on SignIn button for Fpl_tc1
And User should be on the Request Manager page for Fpl_tc1
And User is navigating to programme manager to select Fee Payable Licensing for Fpl_tc1
And User is on Fee Payable Licensing page for editing parameters summary for Fpl_tc1
And User select the appropriate options for the Rights Granted panel for Fpl_tc1
And User fill the appropriate options for the Pricing Settings panel for Fpl_tc1
And search for individual titles for to set Fee Payable Licensing parameters for Fpl_tc1
And make a permissions request for Fpl_tc1
And ISBN/ISSN search for a title to get permission for Fpl_tc1
And fill the appropriate details of Select Content for the title of Fpl_tc1
And fill the appropriate options of Details of Content for the title of Fpl_tc1
And fill the appropriate details Select Planned Use for the title of Fpl_tc1
And fill the appropriate options Details of Usage for the title of Fpl_tc1
And set the details of Review Request for the title of Fpl_tc1
And check the status that request is sent for Fpl_tc1
And see the request is submitted as sent request for Fpl_tc1
Then set the default parameter settings for the title of Fpl_tc1

细分为: 现在将其设置为从单元格(1048576,1)开始

pasteSheet.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)

,直到找到一个非空白的单元格为止。

pasteSheet.Cells(Rows.Count, 1)

偏移量仅将单元格值偏移1行。 (例如,如果最后一个空白行是12, 将粘贴到单元格13)

.End(xlUp)

您需要的是:

.Offset(1, 0)