Advertisement
| 10.03.2008 at 09:29AM PDT, ID: 23785611 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: |
'
' ownership Macro
'
' Keyboard Shortcut: Ctrl+u
'
Dim ws As Worksheet, ws1 As Worksheet, rng As Range, rng2 As Range
Dim H As Range
'On Error Resume Next
Set H = Application.InputBox("Please select sheet from which data need to be moved", Type:=8)
If H Is Nothing Then Exit Sub
ActiveWorkbook.Names.Add Name:="Data", RefersTo:=H
Application.Goto Reference:="Data"
Set ws = ActiveSheet
ActiveWorkbook.Names.Add Name:="Data", RefersTo:=ws.Range("G11:CE11")
ActiveWorkbook.Names.Add Name:="Data1", RefersTo:=ws.Range("G9:CE9")
Set rng = ws.Range("G11:CE11")
Set H = Application.InputBox("Please select the sheet to which data need to be moved", Type:=8)
If H Is Nothing Then Exit Sub
ActiveWorkbook.Names.Add Name:="Data3", RefersTo:=H
Application.Goto Reference:="Data3"
Application.ScreenUpdating = False
Set ws1 = ActiveSheet
ws.Select
Range("G11").Select
stcol = ActiveCell.Column
Do Until Trim(ActiveCell.Value) = ""
ActiveCell.Offset(0, 1).Select
encol = ActiveCell.Column - 1
Loop
Range(Cells(11, stcol).Address & ":" & Cells(11, encol).Address).Copy
ws1.Select
Range("a" & Cells(65536, "a").End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlValues, Transpose:=True
ws.Select
Range(Cells(3, stcol).Address & ":" & Cells(3, encol).Address).Copy
ws1.Select
Range("b" & Cells(65536, "b").End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlValues, Transpose:=True
Selection.NumberFormat = "??????/??????"
ws.Select
Range(Cells(9, stcol).Address & ":" & Cells(9, encol).Address).Copy
ws1.Select
Range("c" & Cells(65536, "c").End(xlUp).Row + 1).Select
Selection.PasteSpecial Paste:=xlValues, Transpose:=True
Cells.Select
Selection.EntireColumn.AutoFit
Range("a2").Select
a = 2
Dim rng1 As Range
Set rng1 = Range("A2:A" & Cells(65536, "A").End(xlUp).Row)
Do Until a > Cells(65536, "a").End(xlUp).Row
x = Application.WorksheetFunction.CountIf(rng, ActiveCell.Value)
y = Application.Evaluate("Sumproduct((Data=""" & ActiveCell.Value & """)*(Data1=" & ActiveCell.Offset(0, 2).Value & "))")
If (ActiveCell.Offset(0, 2).Value = 0 Or ActiveCell.Value = "" Or x = 0 Or Application.WorksheetFunction.CountIf(rng1, ActiveCell.Value) > x Or y = 0) Then
Rows(a).Delete
Range("a" & a).Select
Else
ActiveCell.Offset(1, 0).Select
a = a + 1
End If
Loop
Range("a1").Select
Application.CutCopyMode = False
ws.Select
Dim Nme As Name
For Each Nme In Names
Nme.Delete
Next Nme
Range("a1").Select
Application.ScreenUpdating = True
End Sub
|
Advertisement