Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can somebody explain what this code is doing. I just don't understand it.
This is from an existing macro; I understand the code but not these sections of it. I need to alter my macro but don't dare until I understand all sections of it. Thanks Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4)) Set rng2 = Intersect(rng.EntireRow, .Columns(2)) Set rng3 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2)) Set rng4 = Intersect(rng.EntireRow, .Columns(4)) rng1.Copy rng3.Offset(0, -1) rng2.Copy rng3.Offset(0, 2) |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub Demo()
Dim rng As Range, rng1 As Range Dim rng2 As Range, rng3 As Range Dim rng4 As Range With ActiveSheet Set rng = .Range("A5,A7:A9,A12") Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4)) Set rng2 = Intersect(rng.EntireRow, .Columns(2)) Set rng3 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2)) Set rng4 = Intersect(rng.EntireRow, .Columns(4)) End With Debug.Print "rng1: ", rng1.Address Debug.Print "rng2: ", rng2.Address Debug.Print "rng3: ", rng3.Address Debug.Print "rng4: ", rng4.Address End Sub produces: rng1: $A$5:$D$5,$A$7:$D$9,$A$12:$D$12 rng2: $B$5,$B$7:$B$9,$B$12 rng3: $A$5:$B$5,$A$7:$B$9,$A$12:$B$12 rng4: $D$5,$D$7:$D$9,$D$12 -- Regards, Tom Ogilvy "glensfallslady" wrote: Can somebody explain what this code is doing. I just don't understand it. This is from an existing macro; I understand the code but not these sections of it. I need to alter my macro but don't dare until I understand all sections of it. Thanks Set rng1 = Intersect(rng.EntireRow, .Columns(1).Resize(, 4)) Set rng2 = Intersect(rng.EntireRow, .Columns(2)) Set rng3 = Intersect(rng.EntireRow, .Columns(1).Resize(, 2)) Set rng4 = Intersect(rng.EntireRow, .Columns(4)) rng1.Copy rng3.Offset(0, -1) rng2.Copy rng3.Offset(0, 2) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
FORMULA EXPLANATION | New Users to Excel | |||
Explanation of when & how to use ( ) { } : ; , ! etc? | New Users to Excel | |||
Explanation needed for CopyAllModules code | Excel Programming | |||
Explanation of code | Excel Programming | |||
Explanation of code | Excel Programming |