Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to write a macro that copies cells in a specific row and then
loops to the next row, next row being 5 rows below. So, copy cells C7, D7 to H7 then, Copy the next set C12, D12 ... H12 and so on. I would assume this would be done using 2 loops, one for goings through the columns and one for the rows, but I could be wrong. I am not sure of the syntax, so if anyone can give me some tips, that would be great. Thanks. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Don't know if this is what you wanted. Following macro will add number
1 on cells C7, D7 to H7 and C12, D12 ... H12 etc. You replace the 1 with your formula Sub TEST() Range("C7").Select For i = 0 To 10 For j = 0 To 5 ActiveCell.Offset(i * 5, j).Value = 1 Next j Next i End Sub On 26 syys, 16:52, Omar wrote: I need to write a macro that copies cells in a specific row and then loops to the next row, next row being 5 rows below. So, copy cells C7, D7 to H7 then, Copy the next set C12, D12 ... H12 and so on. I would assume this would be done using 2 loops, one for goings through the columns and one for the rows, but I could be wrong. I am not sure of the syntax, so if anyone can give me some tips, that would be great. Thanks. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On Sep 26, 10:01 am, HI wrote:
Don't know if this is what you wanted. Following macro will add number 1 on cells C7, D7 to H7 and C12, D12 ... H12 etc. You replace the 1 with your formula Sub TEST() Range("C7").Select For i = 0 To 10 For j = 0 To 5 ActiveCell.Offset(i * 5, j).Value = 1 Next j Next i End Sub Thanks, that makes sense. I had another question my original formula was just extracting the first 3 chars from a specific cell, now as I have to loop through the columns and rows, the following won't work: id = Range("C7").Characters(1, 3).Text Using you method, how would I integrate this into the code? ActiveCell.Offset(i * 5, j).Value = 1 is inserting '1' into those cells. How do I make it copy those cells instead? |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am tying the following, but it doesn't seem to work
Range("B7").Select For i = 0 To 10 For j = 0 To 6 ActiveCell.Offset(i * 5, j).Select Selection.Copy Windows("Test.xls").Activate ActiveCell.Range("A2").Select ActiveSheet.Paste Next j Next i |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Run from the sheet with the source data and change sheet27 to suit
sub copyevery7() With Sheets("sheet27") ..Columns("H:z").Delete For i = 7 To Cells(Rows.Count, "c").End(xlUp).Row Step 7 lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1 Cells(i, "c").Resize(, 4).Copy .Cells(lr, "h") Next i End With End Sub -- Don Guillett Microsoft MVP Excel SalesAid Software "Omar" wrote in message ps.com... I am tying the following, but it doesn't seem to work Range("B7").Select For i = 0 To 10 For j = 0 To 6 ActiveCell.Offset(i * 5, j).Select Selection.Copy Windows("Test.xls").Activate ActiveCell.Range("A2").Select ActiveSheet.Paste Next j Next i |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() for i = 7 to whatever step 5 cells(i,"c").resize(,2) copy cells(i,"h") next i -- Don Guillett Microsoft MVP Excel SalesAid Software "Omar" wrote in message oups.com... I need to write a macro that copies cells in a specific row and then loops to the next row, next row being 5 rows below. So, copy cells C7, D7 to H7 then, Copy the next set C12, D12 ... H12 and so on. I would assume this would be done using 2 loops, one for goings through the columns and one for the rows, but I could be wrong. I am not sure of the syntax, so if anyone can give me some tips, that would be great. Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Counting characters in multiple rows when rows meet specific criteria | Excel Worksheet Functions | |||
Loop thru lines of text in a cell and extract specific values: please help? | Excel Programming | |||
Exclude specific wks in FOR EACH wks Loop | Excel Programming | |||
Loop through specific worksheets | Excel Programming | |||
Macro/Loop If Statement Help -delete the row with the specific te | Excel Programming |