Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Can I use loops to enhance this code?

Can I use loops to enhance this code?
Sheet24.Cells(5, 2).Copy Destination:=Sheet5.Cells(10, 3)
Sheet24.Cells(5, 3).Copy Destination:=Sheet5.Cells(10, 4)
Sheet24.Cells(5, 4).Copy Destination:=Sheet5.Cells(11, 3)
Sheet24.Cells(5, 5).Copy Destination:=Sheet5.Cells(11, 4)
Sheet24.Cells(5, 6).Copy Destination:=Sheet5.Cells(12, 3)
Sheet24.Cells(5, 7).Copy Destination:=Sheet5.Cells(12, 4)
Sheet24.Cells(5, 8).Copy Destination:=Sheet5.Cells(13, 3)
Sheet24.Cells(5, 9).Copy Destination:=Sheet5.Cells(13, 4)
Sheet24.Cells(5, 10).Copy Destination:=Sheet5.Cells(14, 3)
Sheet24.Cells(5, 11).Copy Destination:=Sheet5.Cells(14, 4)
Sheet24.Cells(5, 12).Copy Destination:=Sheet5.Cells(15, 3)
Sheet24.Cells(5, 13).Copy Destination:=Sheet5.Cells(15, 4)
Sheet24.Cells(5, 14).Copy Destination:=Sheet5.Cells(16, 3)
Sheet24.Cells(5, 15).Copy Destination:=Sheet5.Cells(16, 4)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 91
Default Can I use loops to enhance this code?

Sub LoopEffect()

Dim Sheet24 As Worksheet, Sheet5 As Worksheet
Dim i As Long, j As Long

Set Sheet24 = Worksheets(2)
Set Sheet5 = Worksheets(3)

For i = 2 To 15
j = i Mod 2
Sheet5.Cells((9 + (i - j) / 2), j + 3) = Sheet24.Cells(5,
i).Value
Next i

End Sub

Pls check.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Can I use loops to enhance this code?

That worked perfectly - thank you very much!!
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
Enhance sumproduct to return unique employee code count Max Excel Worksheet Functions 5 December 4th 07 05:54 PM
help with loops in code, Paul Excel Programming 3 April 17th 06 02:26 AM
code loops 1024 times not what i ask Rob Hargreaves[_2_] Excel Programming 3 August 7th 05 11:36 AM
ADO & Loops: error in code? Santiago[_2_] Excel Programming 2 July 28th 05 07:25 PM
Help on writing code more efficiently (Loops) Kathryn[_5_] Excel Programming 3 May 25th 04 08:45 PM


All times are GMT +1. The time now is 09:09 PM.

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

About Us

"It's about Microsoft Excel"