![]() |
copy paste for each cell in an array
I'm trying to copy paste from one worksheet to another via VBA. My first
attempt resulted in an error as soon as a blank cell was encountered. So I came up with the following code. The For...Next and If...Then work fine - the problem is with the copy/paste lines. I'd appreciate the help (and a little explaination so I don't gum it up again the next time). Here's the <snipped code: myAddresses = Array("A12:A35,A37:C48,L12:O48,L49:M56,L58:L59") For RangeCounter = LBound(myAddresses) To UBound(myAddresses) Set BCRange = Nothing On Error Resume Next Set BCRange = wsh1.Range(myAddresses(RangeCounter)) For Each cell In BCRange.Cells If cell.HasFormula = True Then wsh1.Range(myAddresses(RangeCounter)).Range(cell). Copy NewWbk.Worksheets("Basic Components Pricing").Activate wsh2.Range(myAddresses(RangeCounter)).PasteSpecial _ xlPasteFormulas ElseIf cell.Value 0 Then wsh1.Range(myAddresses(RangeCounter)).Range(cell). Copy NewWbk.Worksheets("Basic Components Pricing").Activate wsh2.Range(myAddresses(RangeCounter)).Range _(cell).PasteSpecial xlPasteValues Else End If Next cell Next RangeCounter -- rpw |
All times are GMT +1. The time now is 05:06 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com