Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default "NxtRow = Cells(Rows.Count," giving me fits

I have used this very line of code successfully in other macros but here it errors out.

With cursor at the end of that line, Run DeBug - run to cursor gives me a yellow highlight. (NxtRow = Nothing)

Thanks.
Howard

Option Explicit

Sub Copy_All_Sheet_Sheet()
Dim WS As Worksheet
Dim NxtRow As Long
Dim Nws As Long

NxtRow = Cells(Rows.Count, "A").End(xlUp)(2).Row

For Nws = 2 To ThisWorkbook.Worksheets.Count
WS.UsedRange.Copy Sheets("Page 1").Range("A" & NxtRow)
Next Nws

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default "NxtRow = Cells(Rows.Count," giving me fits

Hi Howard,

Am Sun, 19 May 2013 06:45:40 -0700 (PDT) schrieb Howard:

I have used this very line of code successfully in other macros but here it errors out.

With cursor at the end of that line, Run DeBug - run to cursor gives me a yellow highlight. (NxtRow = Nothing)


try:

With Sheets("Page 1")
For Nws = 2 To ThisWorkbook.Worksheets.Count
NxtRow = .Cells(.Rows.Count, "A").End(xlUp)(2).Row
Sheets(Nws).UsedRange.Copy .Range("A" & NxtRow)
Next Nws
End With

Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default "NxtRow = Cells(Rows.Count," giving me fits

Hi Howard,

Am Sun, 19 May 2013 17:25:07 +0200 schrieb Claus Busch:

With Sheets("Page 1")
For Nws = 2 To ThisWorkbook.Worksheets.Count
NxtRow = .Cells(.Rows.Count, "A").End(xlUp)(2).Row
Sheets(Nws).UsedRange.Copy .Range("A" & NxtRow)
Next Nws
End With


or try:

Sub Copy_All_Sheet_Sheet()
Dim Nws As Integer
Dim NxtC As Range

With Sheets("Page 1")
For Nws = 2 To ThisWorkbook.Worksheets.Count
Set NxtC = .Cells(.Rows.Count, "A").End(xlUp)(2)
Sheets(Nws).UsedRange.Copy NxtC
Next Nws
End With
End Sub


Regards
Claus Busch
--
Win XP PRof SP2 / Vista Ultimate SP2
Office 2003 SP2 /2007 Ultimate SP2
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 536
Default "NxtRow = Cells(Rows.Count," giving me fits

On Sunday, May 19, 2013 10:34:34 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Sun, 19 May 2013 17:25:07 +0200 schrieb Claus Busch:



With Sheets("Page 1")


For Nws = 2 To ThisWorkbook.Worksheets.Count


NxtRow = .Cells(.Rows.Count, "A").End(xlUp)(2).Row


Sheets(Nws).UsedRange.Copy .Range("A" & NxtRow)


Next Nws


End With




or try:



Sub Copy_All_Sheet_Sheet()

Dim Nws As Integer

Dim NxtC As Range



With Sheets("Page 1")

For Nws = 2 To ThisWorkbook.Worksheets.Count

Set NxtC = .Cells(.Rows.Count, "A").End(xlUp)(2)

Sheets(Nws).UsedRange.Copy NxtC

Next Nws

End With

End Sub





Regards

Claus Busch

--

Win XP PRof SP2 / Vista Ultimate SP2

Office 2003 SP2 /2007 Ultimate SP2


Works dandy.

Thanks Claus.

Regards,
Howard
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
Destination:=.Cells(.Rows.Count, "A").End(xlUp).Row + 1 J.W. Aldridge Excel Programming 5 May 6th 09 09:10 PM
Count cells that contain "Y" in columnA IF contains"X" in columnB holliedavis Excel Worksheet Functions 6 July 20th 06 06:12 PM
Cells(Rows.Count, "b").End(xlUp).Row Kate[_2_] Excel Programming 1 May 25th 06 04:31 PM
Count occurences of "1"/"0" (or"TRUE"/"FALSE") in a row w. conditions in the next BCB New Users to Excel 7 May 13th 06 10:02 PM
"Clean Me" Macro is giving "#VALUE!" error in the Notes field. Ryan Watkins Excel Programming 1 June 11th 05 12:25 AM


All times are GMT +1. The time now is 10:22 PM.

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

About Us

"It's about Microsoft Excel"