ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   simple for each (https://www.excelbanter.com/excel-programming/375212-simple-each.html)

John

simple for each
 
any help is appreciated... I am not getting it to select or evaluate each rg

Range("b65536").End(xlUp).Select
rnglst = ActiveCell.Row

For Each rg In Range("a10:" & Range("a" & rnglst))
rg.Select
If rg 0 Then
rg.Copy
rg.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
Next

Jim Thomlinson

simple for each
 
Give this a try. It is a little more compact than your original post...

dim rg as range

For Each rg In Range(Range("a10:"), cells(Rows.count, "A").end(xlUp))
If rg 0 Then rg.Offset(0, 1).Value = rg.value
Next rg
--
HTH...

Jim Thomlinson


"John" wrote:

any help is appreciated... I am not getting it to select or evaluate each rg

Range("b65536").End(xlUp).Select
rnglst = ActiveCell.Row

For Each rg In Range("a10:" & Range("a" & rnglst))
rg.Select
If rg 0 Then
rg.Copy
rg.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
Next


John

simple for each
 
I did it the first way because I was testing the bottom row in colum B...
there is still probablly an easier way but this one won't work for my set up.
But the first post works great... thank you again

"Jim Thomlinson" wrote:

Give this a try. It is a little more compact than your original post...

dim rg as range

For Each rg In Range(Range("a10:"), cells(Rows.count, "A").end(xlUp))
If rg 0 Then rg.Offset(0, 1).Value = rg.value
Next rg
--
HTH...

Jim Thomlinson


"John" wrote:

any help is appreciated... I am not getting it to select or evaluate each rg

Range("b65536").End(xlUp).Select
rnglst = ActiveCell.Row

For Each rg In Range("a10:" & Range("a" & rnglst))
rg.Select
If rg 0 Then
rg.Copy
rg.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
Next



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

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