Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ranges and the union method

Status
Not open for further replies.

caerdydd

Programmer
Mar 2, 2004
35
GB
Hi all

I am trying to union two ranges containing numbers which i then want to sum. In the ranges which start from F7 there will always be a gap to the next range, it will start from F9 or F10 or F11 and so on and so forth. But the answer to my sum formula always gives me the value from F7 rather than the sum of all cells in the entire union. Anyone know what i am doing wrong? Thanks for the help in advance.



Sub union_it()
Dim rng1, rng2, therng As Range

Set rng1 = Sheet1.Cells.Range("F7")
Set rng2 = Sheet1.Cells.Range("F9:F13")

Set therng = Application.Union(rng1, rng2)
Application.Sum (therng)
MsgBox therng
End Sub
 
And what about this ?
MsgBox Application.Sum(therng)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top