|
- Private Sub CopyRng()
- Dim Rng As Range, oRng As Range
- Dim Rr As Range
-
- Dim Rng1 As Range, Rng2 As Range
- Set Rng = Selection
- Dim Sht As Worksheet
- Set Sht = Application.Worksheets("GeneralTable")
- Sht.Activate
- Dim oRow:
- oRow = Sht.Range("C65536").End(3).Row
- If oRow < 3 Then
- oRow = 9
- End If
- ''
- Set Rng = Sht.Range("A3:N" & oRow)
- ''Debug.Print Rng.Address
- Rng.ClearContents
- Rng.UnMerge
- Rng.Font.Size = 9
- Rng.ClearFormats
- ''
- oRow = 3
- Set Rng = Application.Range(Sht.Cells(1, "A").Formula)
-
- 'Set Rng1 = Application.Range(Sht.Cells(1, "B").Formula)
- Set Rng2 = Application.Range(Sht.Cells(1, "C").Formula)
- ''
- Set Rr = Application.Range(Sht.Cells(1, "G").Formula)
- Dim R1 As Range, R2 As Range, R3 As Range
- Set R1 = Application.Range(Sht.Cells(1, "D").Formula)
- Set R2 = Application.Range(Sht.Cells(1, "E").Formula)
- Set R3 = Application.Range(Sht.Cells(1, "F").Formula)
-
-
- ''
- For ii = 1 To Rng.Rows.Count
- Set Rng1 = Application.Range(Sht.Cells(1, "B").Formula)
- Select Case Rng(ii, 19)
- Case "A6", "A7", "A8"
- Rng1.Copy
- Case Else
- Set Rng1 = Rng1.Resize(Rng1.Rows.Count - 1, Rng1.Columns.Count)
- Rng1.Copy
- End Select
- Sht.Cells(oRow, 1) = Rng(ii, 1) & ".SLDDRW"
-
- Sht.Cells(oRow + 1, 1).PasteSpecial
- Sht.Cells(oRow + 1, 1) = Rng(ii, 1)
- ''
- Set oRng = Sht.Cells(oRow + 1, "A").Resize(Rng1.Rows.Count, Rng1.Columns.Count)
- Rng(ii, 20) = Rng1.Parent.Name & "!" & oRng.Address
-
- Select Case Rng(ii, 19)
- Case "A6", "A7", "A8"
- Set oRng = oRng.Resize(Rng.Rows.Count, 1)
- ''Debug.Print oRng.Address
- oRng.MergeCells = True
- End Select
- ''
- Rr.Copy
- Set oRng = Sht.Cells(oRow + R1.Row - Rng1.Row, 1 + R1.Column - Rng1.Column)
- oRng.PasteSpecial
- Set oRng = oRng(2, 1).Resize(R1.Rows.Count, R1.Columns.Count)
- 'Debug.Print oRng.Address
- Rng(ii, 21) = Rng1.Parent.Name & "!" & oRng.Address
-
- ''
- Set oRng = Sht.Cells(oRow + R2.Row - Rng1.Row, 1 + R2.Column - Rng1.Column)
- oRng.PasteSpecial
- Set oRng = oRng(2, 1).Resize(R2.Rows.Count, R2.Columns.Count)
- 'Debug.Print oRng.Address
- Rng(ii, 22) = Rng1.Parent.Name & "!" & oRng.Address
- ''
- Set oRng = Sht.Cells(oRow + R3.Row - Rng1.Row, 1 + R3.Column - Rng1.Column)
- oRng.PasteSpecial
- Select Case Rng(ii, 19)
- Case "A6", "A7", "A8"
- Set oRng = oRng(2, 1).Resize(R3.Rows.Count, R3.Columns.Count)
- Case Else
- Set oRng = oRng(2, 1).Resize(R3.Rows.Count - 1, R3.Columns.Count)
- End Select
- 'Debug.Print oRng.Address
- 'Stop
- Rng(ii, 23) = Rng1.Parent.Name & "!" & oRng.Address
- ''
-
-
- ''
- Rng2.Copy
- Sht.Cells(oRow + 1, "N").PasteSpecial
- For jj = 1 To Rng2.Rows.Count
- If Not IsEmpty(Rng2(jj, 1)) Then
- Sht.Cells(oRow + jj, 2) = Rng2(jj, 2)
- End If
- Next jj
- 'Stop
- oRow = oRow + 1 + Rng1.Rows.Count
- Next ii
- End Sub
复制代码
|
|