ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   More Visual Basic Syntax (https://www.excelbanter.com/excel-programming/281307-more-visual-basic-syntax.html)

Al[_12_]

More Visual Basic Syntax
 
I need help figuring out the syntax for using the counter
from a 'For' loop in the cell references. I marked the
lines I have wrong w/ 'X'. Both errors involve passing
the value of 'counter' into a 'Range' statement to specify
the row number in a Cell designation.

Dim counter As Integer
Dim temp As String
For counter = 1 To 10
temp = Worksheets("Sheet1").Cells(counter, 1).Value
Select Case temp
Case apple
X Range("A'counter':H'counter'").Select
Selection.Copy
Sheets("Sheet2").Select
X Range("A'counter+43'").Select
ActiveSheet.Paste
Case ....
End Select
Next i


Kevin Stecyk

More Visual Basic Syntax
 
Al,

See below.

Regards,
Kevin

Dim counter As Integer
Dim temp As String
For counter = 1 To 10
temp = Worksheets("Sheet1").Cells(counter, 1).Value
Select Case temp
Case apple
Range("A" & counter & ":H" & counter).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A" & counter+43 ).Select
ActiveSheet.Paste
Case ....
End Select
Next i




"Al" wrote in message
...
I need help figuring out the syntax for using the counter
from a 'For' loop in the cell references. I marked the
lines I have wrong w/ 'X'. Both errors involve passing
the value of 'counter' into a 'Range' statement to specify
the row number in a Cell designation.

Dim counter As Integer
Dim temp As String
For counter = 1 To 10
temp = Worksheets("Sheet1").Cells(counter, 1).Value
Select Case temp
Case apple
X Range("A'counter':H'counter'").Select
Selection.Copy
Sheets("Sheet2").Select
X Range("A'counter+43'").Select
ActiveSheet.Paste
Case ....
End Select
Next i




Al[_12_]

More Visual Basic Syntax
 

Awesome ... Thx Much Kevin!!!


-----Original Message-----
Al,

See below.

Regards,
Kevin

Dim counter As Integer
Dim temp As String
For counter = 1 To 10
temp = Worksheets("Sheet1").Cells(counter,

1).Value
Select Case temp
Case apple
Range("A" & counter & ":H" &

counter).Select
Selection.Copy
Sheets("Sheet2").Select
Range("A" & counter+43 ).Select
ActiveSheet.Paste
Case ....
End Select
Next i




"Al" wrote in message
...
I need help figuring out the syntax for using the

counter
from a 'For' loop in the cell references. I marked the
lines I have wrong w/ 'X'. Both errors involve passing
the value of 'counter' into a 'Range' statement to

specify
the row number in a Cell designation.

Dim counter As Integer
Dim temp As String
For counter = 1 To 10
temp = Worksheets("Sheet1").Cells(counter,

1).Value
Select Case temp
Case apple
X Range("A'counter':H'counter'").Select
Selection.Copy
Sheets("Sheet2").Select
X Range("A'counter+43'").Select
ActiveSheet.Paste
Case ....
End Select
Next i



.



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

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