本文介绍了在工作表中的列和行中选择UsedRange的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  • 我的excel文件中有两张表, DTMGIS DTMEdit

  • DTMEdit 工作表为空

  • 我正在尝试从 DTMGIS ,然后仅将值粘贴到工作表 DTMEdit

  • I have two sheets in my excel file, DTMGIS and DTMEdit
  • the DTMEdit sheet is empty
  • and I am trying to xopy everything from DTMGIS and Paste only Values to Sheet DTMEdit

我不知道如何仅选择 UsedRange 并将其粘贴到 DMTEdfit

I do not know how to select the UsedRange only and paste this to DMTEdfit

Dim ws As Worksheet
Dim LastRow As Long, LastCoulmn As Long, Header As Long
Header = 2
Set ws = ThisWorkbook.Sheets("DTMGIS")
LastRow = ws.UsedRange.Rows.Count
LastCoulmn = ws.UsedRange.Column.Count

With ws.UsedRange
    .Select
    .Copy
End With


推荐答案

尝试这样的东西:

Try something like this:

Sub CopyPasteValues()
    Dim ws1 As Worksheet, ws2 As Worksheet

    Set ws1 = ThisWorkbook.Sheets("DTMGIS")
    Set ws2 = ThisWorkbook.Sheets("DTMEdit")

    ws1.Range(ws1.UsedRange.Address).Copy
    ws2.Range("a1").PasteSpecial xlPasteValues
End Sub

这篇关于在工作表中的列和行中选择UsedRange的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 22:01