#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Move values

What can be wrong?

Sub copy()
Dim rng As Range, cell As Range
Dim rw As Long
Dim cLastRow As Long

On Error Resume Next
Set rng = Range("G3:G4510").SpecialCells(xlFormulas, xlErrors)
On Error GoTo 0
rw = 0
If Not rng Is Nothing Then
For Each cell In rng
If cell.Text = "#N/A" Then
rw = rw + 1
End If


Sheets("Sheet1").Select
cLastRow = Cells(Rows.Count, "C").End(xlUp).Row
Range("C" & cLastRow).Offset(1, 0).Select


Sheets("Sheet1").Cells(rw, "C").Value =
Sheets("Sheet2").Cells(cell.Row, "A").Value


Next
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Move values

I don't see a reason for this portion:

Sheets("Sheet1").Select
cLastRow = Cells(Rows.Count, "C").End(xlUp).Row
Range("C" & cLastRow).Offset(1, 0).Select

(I'd comment it out and see if made any difference.)

And you only add to the rw variable when you have an error that evaluates to
#N/A. What about #value!, #ref!, etc?

But I'm not sure what you're really asking for. You may want to be more
explicit with what you want and what isn't working.

Geir wrote:

What can be wrong?

Sub copy()
Dim rng As Range, cell As Range
Dim rw As Long
Dim cLastRow As Long

On Error Resume Next
Set rng = Range("G3:G4510").SpecialCells(xlFormulas, xlErrors)
On Error GoTo 0
rw = 0
If Not rng Is Nothing Then
For Each cell In rng
If cell.Text = "#N/A" Then
rw = rw + 1
End If


Sheets("Sheet1").Select
cLastRow = Cells(Rows.Count, "C").End(xlUp).Row
Range("C" & cLastRow).Offset(1, 0).Select


Sheets("Sheet1").Cells(rw, "C").Value =
Sheets("Sheet2").Cells(cell.Row, "A").Value


Next
End If
End Sub


--

Dave Peterson
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
Move Y axis values from right to left Ken G. Charts and Charting in Excel 3 April 3rd 23 02:14 PM
find and move values <0 Sojo Excel Worksheet Functions 6 September 27th 08 03:02 PM
Move the Y axis below negative values Vic Mel Charts and Charting in Excel 2 January 14th 06 02:24 PM
Move column values w/o formula Greg Excel Worksheet Functions 1 February 1st 05 10:01 PM
identify and move specific values phyrn Excel Programming 0 September 17th 04 08:53 PM


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

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"