ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Column and row advance (https://www.excelbanter.com/excel-discussion-misc-queries/230108-column-row-advance.html)

JTWarthogs

Column and row advance
 
I asked this earlier but it may not have been clear. To advance the rows in
a for statement is easy. So in the case below it is checking from A1 to A31
for the date and when it matches it copies over to the B and C columns.

So how do you check from columns B, C, D, E, and F? so I could do another
For/next statement inside to go from B to F so let column=a, then column =
column + ???? so that it goes to B, then cycles through the loop and goes to
C and so on until it cycles through 5 times 9 from B to F. I know that the +1
does not work so how can you cycle through letters?

Dim i As Integer
Let i = 1
For i = 1 To 31
If datecurrent = Worksheets("73-1 Data").Range("a" & i) Then
Worksheets("73").Range("b40").Copy Destination:=Worksheets("73-1
Data").Range("b" & i)
Worksheets("73").Range("b41").Copy Destination:=Worksheets("73-1
Data").Range("c" & i)
Worksheets("73").Range("b42").Copy Destination:=Worksheets("73-1
Data").Range("d" & i)
Worksheets("73").Range("b43").Copy Destination:=Worksheets("73-1
Data").Range("e" & i)
Worksheets("73").Range("b44").Copy Destination:=Worksheets("73-1
Data").Range("f" & i) Endif
Next i

Dim i As Integer
Let i = 1
For i = 1 To 31
If datecurrent = Worksheets("73-1 Data").Range("a" & i) Then
For column = 1 to 5
Worksheets("73").Range("b40").Copy Destination:=Worksheets("73-1
Data").Range(column & i)
column = column +1
Next column
Endif
Next i



JTWarthogs

Column and row advance
 
I got it

Let i = 1
For i = 1 To 31
If datecurrent = Worksheets("73-1 Data").Range("a" & i) Then
For column = 2 To 6
Worksheets("73").Range("b40").Copy Destination:=Worksheets("73-1
Data").Cells(i, column)
Next column
Endif
Next i

"JTWarthogs" wrote:

I asked this earlier but it may not have been clear. To advance the rows in
a for statement is easy. So in the case below it is checking from A1 to A31
for the date and when it matches it copies over to the B and C columns.

So how do you check from columns B, C, D, E, and F? so I could do another
For/next statement inside to go from B to F so let column=a, then column =
column + ???? so that it goes to B, then cycles through the loop and goes to
C and so on until it cycles through 5 times 9 from B to F. I know that the +1
does not work so how can you cycle through letters?

Dim i As Integer
Let i = 1
For i = 1 To 31
If datecurrent = Worksheets("73-1 Data").Range("a" & i) Then
Worksheets("73").Range("b40").Copy Destination:=Worksheets("73-1
Data").Range("b" & i)
Worksheets("73").Range("b41").Copy Destination:=Worksheets("73-1
Data").Range("c" & i)
Worksheets("73").Range("b42").Copy Destination:=Worksheets("73-1
Data").Range("d" & i)
Worksheets("73").Range("b43").Copy Destination:=Worksheets("73-1
Data").Range("e" & i)
Worksheets("73").Range("b44").Copy Destination:=Worksheets("73-1
Data").Range("f" & i) Endif
Next i

Dim i As Integer
Let i = 1
For i = 1 To 31
If datecurrent = Worksheets("73-1 Data").Range("a" & i) Then
For column = 1 to 5
Worksheets("73").Range("b40").Copy Destination:=Worksheets("73-1
Data").Range(column & i)
column = column +1
Next column
Endif
Next i




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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com