Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default simple for each problem

any ideas why this is incorrect? Thanks for your help!

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default simple for each problem

You ave to add .Address to this line
For Each rg In Range("a10:" & Range("a" & rnglst))
like this
For Each rg In Range("a10:" & Range("a" & rnglst).Address)
otherwise Range("a" & rnglst) returns the value in that cell and not the
address of the cell (value is the default property of a range, not address).
--
HTH...

Jim Thomlinson


"John" wrote:

any ideas why this is incorrect? Thanks for your help!

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default simple for each problem

this works, thanks Jim

"Jim Thomlinson" wrote:

You ave to add .Address to this line
For Each rg In Range("a10:" & Range("a" & rnglst))
like this
For Each rg In Range("a10:" & Range("a" & rnglst).Address)
otherwise Range("a" & rnglst) returns the value in that cell and not the
address of the cell (value is the default property of a range, not address).
--
HTH...

Jim Thomlinson


"John" wrote:

any ideas why this is incorrect? Thanks for your help!

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple IF problem Trevor Aiston[_2_] Excel Worksheet Functions 0 September 12th 09 03:18 PM
Simple problem, simple formula, no FUNCTION ! Ron@Buy Excel Worksheet Functions 6 September 28th 07 04:51 PM
Simple problem excelnovice1 New Users to Excel 3 June 29th 06 11:19 AM
Help simple problem [email protected] Excel Programming 1 December 21st 05 09:21 PM
Simple problem inquirer Excel Discussion (Misc queries) 4 April 16th 05 12:37 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"