PC Review


Reply
Thread Tools Rate Thread

Can I use loops to enhance this code?

 
 
Max
Guest
Posts: n/a
 
      30th Aug 2011
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)
 
Reply With Quote
 
 
 
 
Javed
Guest
Posts: n/a
 
      30th Aug 2011
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.
 
Reply With Quote
 
Max
Guest
Posts: n/a
 
      30th Aug 2011
That worked perfectly - thank you very much!!
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why the performance difference with the following code loops. Dave Harris Microsoft C# .NET 2 3rd Jun 2009 01:43 AM
Enhance sumproduct to return unique employee code count Max Microsoft Excel Worksheet Functions 5 4th Dec 2007 05:54 PM
Enhance this code =?Utf-8?B?bXJiYWxhamU=?= Microsoft Outlook VBA Programming 1 1st Jan 2007 03:13 PM
help with loops in code, =?Utf-8?B?UGF1bA==?= Microsoft Excel Programming 3 17th Apr 2006 02:26 AM
ADO & Loops: error in code? =?Utf-8?B?U2FudGlhZ28=?= Microsoft Excel Programming 2 28th Jul 2005 07:25 PM


Features
 

Advertising
 

Newsgroups
 


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