![]() |
Need explanation of code please
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) |
Need explanation of code please
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) |
All times are GMT +1. The time now is 08:56 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com