Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi All:
I have a master worksheet that holds several types of data. I also have 10 worksheets (in the same workbook) that may, or may not contain data that I need to copy to the master sheet. I am a bit of a novice with VBA, but have gotten the following code to work. However, I would like to either copy row heights, or possibly the entire row. Each secondary worksheet contains 10 pages, each 67 rows long. Columns are the same width as the master sheet (Some Cells are merged) Can anyone help me get this to perform the checks and then copy the entire row? The current code is as follows: Sub Data_Ranges_Copy_and_Clear() Dim vCopySheets As Variant Dim vCheckPoints As Variant Dim vCopyRange As Variant Dim rng As Range Dim Rng2 As Range Dim Rng3 As Range Dim iCounter As Integer Dim iCounter2 As Integer vCopySheets = Array("Cores", "NPN", "Est", "GOG", "Fact Claim", "OS Claim", "Fact PS", "OS PS", "Prepaid", "Sold During") 'Select each sheet in turn For iCounter = LBound(vCopySheets) To UBound(vCopySheets) Step 1 Sheets(vCopySheets(iCounter)).Select 'Cells on this sheet to test vCheckPoints = Array("A619", "A552", "A485", "A418", "A351", "A284", "A217", "A147", "A83", "A16") 'Corresponding ranges to copy vCopyRange = Array("A1:P670", "A1:P603", "A1:P536", "A1:P469", "A1:P402", "A1:P335", "A1:P268", "A1:P201", "A1:P134", "A1:P67") For iCounter2 = LBound(vCheckPoints) To UBound(vCheckPoints) Step 1 Set rng = Range(vCheckPoints(iCounter2)) If Not (IsEmpty(rng)) Then 'set copy area Set Rng2 = Range(vCopyRange(iCounter2)) 'Before copying find pasting point Set Rng3 = Sheets("INV").Cells(65536, 1).End(xlUp).Offset(1, 0) 'Now copy to other sheet With Rng2 .Copy Rng3 ' .ClearContents End With 'Items found and copied so get out of (inner)loop Exit For End If Next 'Move on to next sheet Next ' Now Clear Data Ranges Dim ws As Worksheet, i As Long For Each ws In Worksheets(Array("Cores", "NPN", "Est", "GOG", "Fact Claim", "OS Claim", "Fact PS", "OS PS", "Prepaid", "Sold During")) For i = 0 To 9 ws.Range("A16:L63").Offset(i * 67).ClearContents Next i Next Sheets("INV").Select End Sub Oh, I forgot to mention, when the copy and paste is complete, I need the original data cleared. Thanks, -- Sam Fowler |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I maintain row heights when copying and pasting | Excel Discussion (Misc queries) | |||
Excel: copy grid, widths & heights down page: heights wrong! why? | Excel Discussion (Misc queries) | |||
How do I sort by complete rows in excell | Excel Worksheet Functions | |||
Return Row Heights for Rows in Active Worksheet - an example | Excel Programming | |||
copying complete column incl. formating | Excel Programming |