ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Intersect or Union? (https://www.excelbanter.com/excel-programming/414438-re-intersect-union.html)

Bob Phillips

Intersect or Union?
 
Public Sub Test()
With antiunion(Sheets(1).UsedRange,range("I44:N55"))
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
End With
End Sub

'-----------------------------------------------------------------
Function AntiUnion(SetRange As Range, UsedRange As Range) As Range
'-----------------------------------------------------------------
Dim saveSet
saveSet = SetRange.Formula
SetRange.ClearContents
UsedRange = 0
Set AntiUnion = SetRange.SpecialCells(xlCellTypeBlanks)
SetRange = saveSet
End Function


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Nigel" wrote in message
...
I have an application that copies the used range on a worksheet and then
pastes values, to remove formula.

I need to deselect a smaller range within the used range before I paste
values, so for the smaller range the formula are retained.

The following replaces all formula, but if I wanted to exclude a smaller
range say ("I44:N55") how could I do this?

With Sheets(1).UsedRange
.Cells.Copy
.Cells.PasteSpecial xlPasteValues
End With



--

Regards,
Nigel








All times are GMT +1. The time now is 02:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com