Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Cells Method Question

I'm trying to step through a workbook, sheet by sheet,
copying data in column A to another column each month.
July goes to column F, August to G, etc. I'm using the
cell method to change the column reference each time. My
data has a number month indicator. I get a run time error
telling me that I must have an object for this method but
my Excel VBA reference says that if I don't specify an
object it defaults to the active sheet. Please help.

Here is my code.

'Copy PivotTable results to appropriate month as values.
Do While x <= NumSheetsToPop
Worksheets(x + 1).Activate
Range("A442:A852").Select
Selection.Copy

ActiveSheet.Cells(PasteRow, Month + 5).Select

Selection.PasteSpecialPaste:=xlPasteValues,Operati on:=xlNon
, SkipBlanks _
:=False, Transpose:=False
x = x + 1
Loop
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Cells Method Question

I don't get an error using your code, but this will be a bit faster:

Do While x <= NumSheetsToPop
With Worksheets(x + 1)
.Cells(PasteRow, myMonth + 5).Resize(411, 1).Value = _
.Range("A442:A852").Value
End With
x = x + 1
Loop

Note that you almost never need to select or activate a range in
order to work with it. Using the range object directly makes your
code smaller, faster and, IMO, easier to maintain.

Note also that I changed your "Month" variable to "myMonth". In
general it's better not to use variable names that are also reserved
word in VBA - it can get very confusing to maintain.

In article ,
"Bonnie" wrote:

I'm trying to step through a workbook, sheet by sheet,
copying data in column A to another column each month.
July goes to column F, August to G, etc. I'm using the
cell method to change the column reference each time. My
data has a number month indicator. I get a run time error
telling me that I must have an object for this method but
my Excel VBA reference says that if I don't specify an
object it defaults to the active sheet. Please help.

Here is my code.

'Copy PivotTable results to appropriate month as values.
Do While x <= NumSheetsToPop
Worksheets(x + 1).Activate
Range("A442:A852").Select
Selection.Copy

ActiveSheet.Cells(PasteRow, Month + 5).Select

Selection.PasteSpecialPaste:=xlPasteValues,Operati on:=xlNon
, SkipBlanks _
:=False, Transpose:=False
x = x + 1
Loop

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
Method for protecting cells which still allows quick editing rbart3 Excel Discussion (Misc queries) 2 December 4th 09 04:24 PM
Please post this thread a correct full method, method about Nast Runsome New Users to Excel 8 February 25th 08 03:29 PM
Please post this thread a complete correct method, method about te Nast Runsome New Users to Excel 0 February 23rd 08 09:42 PM
Question on RATE()-like method for non-straightline values [email protected] Excel Discussion (Misc queries) 0 December 14th 06 08:51 PM


All times are GMT +1. The time now is 01:15 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"