Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Hi all, This is my first post. I am new to excel macros. Please help me. I need to copy from range(H2:M2) in sheet1 and paste it into range(A2) in sheet2, then go to range(H5:M5), copy that and paste in range(A3) and so on.. How do i increment the range in a For loop? Thank you, ET. -- excel_lent ------------------------------------------------------------------------ excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738 View this thread: http://www.excelforum.com/showthread...hreadid=514524 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sub abc()
Dim j as Long, i as Long j = 2 for i = 2 to 100 step 3 cells(i,"H").Resize(1,6).copy _ worksheets("Sheet2").Cells(j,1) j = j + 1 Next end sub -- Regards, Tom Ogilvy "excel_lent" wrote in message ... Hi all, This is my first post. I am new to excel macros. Please help me. I need to copy from range(H2:M2) in sheet1 and paste it into range(A2) in sheet2, then go to range(H5:M5), copy that and paste in range(A3) and so on.. How do i increment the range in a For loop? Thank you, ET. -- excel_lent ------------------------------------------------------------------------ excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738 View this thread: http://www.excelforum.com/showthread...hreadid=514524 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
One way: Sub CopyHM() Dim ws1 As Worksheet Dim ws2 As Worksheet Dim iLastrow As Long, r As Long Set ws1 = Worksheets("Sheet1") Set ws2 = Worksheets("Sheet2") Set orng = ws2.Range("a2") ws1.Select With ws1 iLastrow = .Cells(Rows.count, "H").End(xlUp).Row '<=== last row in column H For r = 2 To iLastrow Step 3 '<=== increment loop by 3 until iLastrow reached ..Cells(r, "H").Resize(1, 6).Copy orng '<=== Resize selects colums H to M (6 columns) Set orng = orng.Offset(1, 0) '<=== set range to next row in Sheet2 Next r End With End Sub HTH "excel_lent" wrote: Hi all, This is my first post. I am new to excel macros. Please help me. I need to copy from range(H2:M2) in sheet1 and paste it into range(A2) in sheet2, then go to range(H5:M5), copy that and paste in range(A3) and so on.. How do i increment the range in a For loop? Thank you, ET. -- excel_lent ------------------------------------------------------------------------ excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738 View this thread: http://www.excelforum.com/showthread...hreadid=514524 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi ET,
Try this. Copy and right click the sheet 1 tab and click on View Code. Paste the code in the sheet module, (the white space). Alt+Tab back to the worksheet and from the Forms tool bar produce a button and assign the macro to it. Change For i = 1 To 4 to the number of times you want to loop. Sub CopyIt() Dim i As Integer Range("H2").Select For i = 1 To 4 ActiveCell.Resize(1, 6).Copy _ Sheets("Sheet2").Range("A100").End(xlUp).Offset(1, 0) ActiveCell.Offset(4, 0).Select Next End Sub HTH Regards, Howard "excel_lent" wrote in message ... Hi all, This is my first post. I am new to excel macros. Please help me. I need to copy from range(H2:M2) in sheet1 and paste it into range(A2) in sheet2, then go to range(H5:M5), copy that and paste in range(A3) and so on.. How do i increment the range in a For loop? Thank you, ET. -- excel_lent ------------------------------------------------------------------------ excel_lent's Profile: http://www.excelforum.com/member.php...o&userid=31738 View this thread: http://www.excelforum.com/showthread...hreadid=514524 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can change range to select active rows instead of :=Range("S10 | Excel Discussion (Misc queries) | |||
When entering data into a range of cells, select the entire range. | Excel Discussion (Misc queries) | |||
select range and put range address in variable | Excel Programming | |||
Compare a selected Range with a Named range and select cells that do not exist | Excel Programming | |||
Select Sheet then Select Range | Excel Programming |