<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - Copying range using VBA doesn't work correctly"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=122684">122684</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Copying range using VBA doesn't work correctly
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>6.1.4.1 rc
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Calc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>GunnarAI@hotmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
When copying cell formulas using VBA, the normal method is:
Worksheets("Sheet1").Range(D4:E6).Copy
Worksheets("Sheet2")Range("D4:E6").PasteSpecial Paste:=xlPasteFormats
What is copied is whatever range that is selected!
To make it work, you must select the range you want to copy:
Add this line first:
Worksheets("Sheet1").Range(D4:E6).Select


Steps to Reproduce:
1.
Worksheets("Sheet1").Range(D4:E6).Copy
Worksheets("Sheet2")Range("D4:E6").PasteSpecial Paste:=xlPasteFormats

2.
Worksheets("Sheet1").Range(D4:E6).Select
Worksheets("Sheet1").Range(D4:E6).Copy
Worksheets("Sheet2")Range("D4:E6").PasteSpecial Paste:=xlPasteFormats


Actual Results:
1. Formatting copied from range that is selected, not the range specified!
2. This solves the problem but isn't the correct way to do format copy

Expected Results:
See Actual Results


Reproducible: Always


User Profile Reset: No



Additional Info:
[Information automatically included from LibreOffice]
Version: 6.1.4.1 (x64)
Build ID: 25073d18caee244880112e52c4a7e71f6081b3a9
CPU threads: 4; OS: Windows 10.0; UI render: GL; 
Locale: nb-NO (nb_NO); Calc: CL</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>