Results 1 to 5 of 5

Thread: Union problem in Excel?

Threaded View

  1. #1

    Thread Starter
    New Member pb1's Avatar
    Join Date
    Jun 2004
    Posts
    7

    Question Union problem in Excel?

    I wish to delete several columns on the same worksheet at one go. So Union was used to group those columns together. But Run-time error 1004 : Method ¡®Union¡¯ of object¡¯_Application¡¯ failed was returned.
    Any way in getting around it please?
    VB Code:
    1. Option Explicit
    2. Dim oExcel As Excel.Application
    3. Dim oWB As Excel.Workbook
    4. Dim oWS As Excel.Worksheet
    5.  
    6. Sub DeleteData ()
    7. Dim rngA As Range
    8.  
    9.         oWB.Activate
    10.         oWB.Sheets(2).Select
    11. 'Autofit Col
    12.         oWB.Sheets(2).Columns ("A:L").EntireColumn.AutoFit    
    13.         Set rngA = oExcel.Union(Columns("F"), Columns("H"))
    14.         rngA.EntireColumn.Delete
    Last edited by pb1; Aug 31st, 2004 at 05:51 PM.
    Give me a hand not a finger.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width