Excel VBA复制和粘贴范围

时间:2018-06-22 10:23:41

标签: excel vba excel-vba

在我的表中,我计算一个数字的素因子,范围是从E6开始。我有以下代码行来确定行数。

server {
 listen 80;
 server_name example.net www.example.net;
 rewrite ^/(.*)$ https://example.net/$1 permanent;
}

server {
  listen 443 ssl; 
  server_name example.net;

  ssl_certificate /etc/letsencrypt/live/example.net/fullchain.pem; 
  ssl_certificate_key /etc/letsencrypt/live/example.net/privkey.pem; 
  include /etc/letsencrypt/options-ssl-nginx.conf;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

  location / {
    root html;
    try_files $uri @example.com;
  }

  location @example.com {
    include replace.conf;
    proxy_pass http://example.com;

    proxy_cookie_domain example.com example.net;

    proxy_set_header Accept-Encoding "";
    proxy_set_header Host example.com;
    proxy_redirect http://example.com http://example.net;

  }
}

负1是排除标题,并且仅获取包含数字的范围。我还设置了范围并复制如下:

# replace direct links
subs_filter "www.example.com" "example.net" gi;
subs_filter "example.com" "example.net" gi;

但是,当我尝试将其粘贴到单元格中时,出现以下错误:

rCount = Application.WorksheetFunction.CountA(Range("E:E")) - 1

这是我到目前为止的编码

Set rgCopy = Range("E6", Selection.End(xlDown))
    Selection.Copy

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

这有效:

Sub test()
Application.ScreenUpdating = False
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).Row

ActiveSheet.Range("E6:E" & LastRow).Copy

LastRow = ActiveSheet.Cells(Rows.Count, "D").End(xlUp).Row

ActiveSheet.Range("D" & LastRow + 5).PasteSpecial xlPasteAll
Application.ScreenUpdating = True
End Sub