LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 586
Default Error using Union in a Loop

I have a range (rngSummary) on a master worksheet that I need to copy to 17
different other worksheets. On that master worksheet I need to use Union to
combine rngSummary with another range (rngDept) that changes for each of the
17 different departments (worksheets). But I am getting a Run Time Error:
That command cannot beb used on multiple selections. Is there another method
I could used to combine these two ranges?

Sub CompileDepts()

' set the global summary schedule
lngLastRow = wksGlobal.Cells(Rows.Count, "A").End(xlUp).Row
Set rngSummary = wksGlobal.Range("A3:K" & lngLastRow)

' compile depts
intDeptColumn = 20
For Each dept In colDepts

Application.StatusBar = "Compiling " & dept.Name & " Department
Schedule...Please Wait."

Set rngDept = wksGlobal.Range(wksGlobal.Cells(3, intDeptColumn), _
wksGlobal.Cells(lngLastRow,
intDeptColumn + 2))
intDeptColumn = intDeptColumn + 3

' copy entire summary and dept column to dept
ERROR Union(rngSummary, rngDept).Copy

' paste values only
.Range("A5").PasteSpecial Paste:=xlPasteValues
Next dept
End Sub
--
Cheers,
Ryan
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Method 'Union' of object '_Application' failed (Runtime Error 1004 vivmaha Excel Programming 3 June 19th 07 01:17 AM
Method 'Union' of object '_Global' failed error sloth Excel Programming 1 October 2nd 06 07:09 AM
Error using 'Union' JNW Excel Programming 4 August 25th 06 03:39 PM
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error rdavis7408 Excel Programming 1 August 25th 04 03:54 AM


All times are GMT +1. The time now is 11:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"