Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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)


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default 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)


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
FORMULA EXPLANATION SSJ New Users to Excel 7 July 26th 07 07:03 PM
Explanation of when & how to use ( ) { } : ; , ! etc? Paul (Sydney Australia) New Users to Excel 4 May 2nd 07 01:54 AM
Explanation needed for CopyAllModules code davidm Excel Programming 5 July 13th 05 10:21 PM
Explanation of code Matt Excel Programming 3 January 15th 04 12:12 PM
Explanation of code marksuza Excel Programming 2 November 21st 03 11:45 AM


All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"