PC Review


Reply
Thread Tools Rate Thread

Copy to next row down....revised.

 
 
pickytweety
Guest
Posts: n/a
 
      13th Apr 2009
Hi,
I have a macro that scrolls through a list of stores, pulling up data
regarding each particular store.
There are two different summary sheets, Summary1 and Summary2. In each
summary sheet Row 3 references other areas of the workbook and provides
different statistics for the particular store. I need the macro to copy row
3 in each sheet and paste it as a value to the first blank row after row 6,
then move on to the next store. The store looping is handled in the "other
code" listed below and that seems to be working. The section of code below
isn't copying and pasting as I was hoping. Is there a different way to write
it? Once again, I just want to copy row three (which changes with each
store) and paste it to row 6, 7, 8, 9 ....and so on--keeping in mind that I
need to do it in both summary sheets. Oh...and I'm hoping to get something
that works in both Excel 2003 and Excel 2007.


'other code.....
CopyToNext wksSummary
CopyToNext wksSummary2
'other code


Sub CopyToNext(wks As Worksheet)

Dim rngfill As Range

With wks
.Outline.ShowLevels RowLevels:=2, ColumnLevels:=2
.Calculate
Set rngfill = Nothing
Set rngfill = .Range("A" & .Rows.Count).End(xlUp)
Set rngfill = rngfill.Offset(1, 0)

Rows("3:3").Copy
rngfill.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

rngfill.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
End With

End Sub


--
Thanks,
PTweety
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th Apr 2009
My first guess is this is the line causing trouble:

Rows("3:3").Copy

I'd use:

.Rows("3:3").Copy

Then it's copying row 3 of wks.

Is that what you wanted?

Actually, I'd use:

.rows(3).copy



pickytweety wrote:
>
> Hi,
> I have a macro that scrolls through a list of stores, pulling up data
> regarding each particular store.
> There are two different summary sheets, Summary1 and Summary2. In each
> summary sheet Row 3 references other areas of the workbook and provides
> different statistics for the particular store. I need the macro to copy row
> 3 in each sheet and paste it as a value to the first blank row after row 6,
> then move on to the next store. The store looping is handled in the "other
> code" listed below and that seems to be working. The section of code below
> isn't copying and pasting as I was hoping. Is there a different way to write
> it? Once again, I just want to copy row three (which changes with each
> store) and paste it to row 6, 7, 8, 9 ....and so on--keeping in mind that I
> need to do it in both summary sheets. Oh...and I'm hoping to get something
> that works in both Excel 2003 and Excel 2007.
>
> 'other code.....
> CopyToNext wksSummary
> CopyToNext wksSummary2
> 'other code
>
> Sub CopyToNext(wks As Worksheet)
>
> Dim rngfill As Range
>
> With wks
> .Outline.ShowLevels RowLevels:=2, ColumnLevels:=2
> .Calculate
> Set rngfill = Nothing
> Set rngfill = .Range("A" & .Rows.Count).End(xlUp)
> Set rngfill = rngfill.Offset(1, 0)
>
> Rows("3:3").Copy
> rngfill.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
>
> rngfill.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
> SkipBlanks:=False, Transpose:=False
>
> Application.CutCopyMode = False
> End With
>
> End Sub
>
> --
> Thanks,
> PTweety


--

Dave Peterson
 
Reply With Quote
 
pickytweety
Guest
Posts: n/a
 
      13th Apr 2009
Exactamundo! Thanks so much--you've saved me from my very bad mood. I had
tried the "period" before "Rows("3:3").Copy" and that didn't work, but the
".rows(3).Copy" worked wonderfully! Why is that? What's the difference?
--
Thanks,
PTweety


"Dave Peterson" wrote:

> My first guess is this is the line causing trouble:
>
> Rows("3:3").Copy
>
> I'd use:
>
> .Rows("3:3").Copy
>
> Then it's copying row 3 of wks.
>
> Is that what you wanted?
>
> Actually, I'd use:
>
> .rows(3).copy
>
>
>
> pickytweety wrote:
> >
> > Hi,
> > I have a macro that scrolls through a list of stores, pulling up data
> > regarding each particular store.
> > There are two different summary sheets, Summary1 and Summary2. In each
> > summary sheet Row 3 references other areas of the workbook and provides
> > different statistics for the particular store. I need the macro to copy row
> > 3 in each sheet and paste it as a value to the first blank row after row 6,
> > then move on to the next store. The store looping is handled in the "other
> > code" listed below and that seems to be working. The section of code below
> > isn't copying and pasting as I was hoping. Is there a different way to write
> > it? Once again, I just want to copy row three (which changes with each
> > store) and paste it to row 6, 7, 8, 9 ....and so on--keeping in mind that I
> > need to do it in both summary sheets. Oh...and I'm hoping to get something
> > that works in both Excel 2003 and Excel 2007.
> >
> > 'other code.....
> > CopyToNext wksSummary
> > CopyToNext wksSummary2
> > 'other code
> >
> > Sub CopyToNext(wks As Worksheet)
> >
> > Dim rngfill As Range
> >
> > With wks
> > .Outline.ShowLevels RowLevels:=2, ColumnLevels:=2
> > .Calculate
> > Set rngfill = Nothing
> > Set rngfill = .Range("A" & .Rows.Count).End(xlUp)
> > Set rngfill = rngfill.Offset(1, 0)
> >
> > Rows("3:3").Copy
> > rngfill.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> >
> > rngfill.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
> > SkipBlanks:=False, Transpose:=False
> >
> > Application.CutCopyMode = False
> > End With
> >
> > End Sub
> >
> > --
> > Thanks,
> > PTweety

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      14th Apr 2009
I think something else broke when you tried ".rows("3:3").copy". That line
should have worked ok.



pickytweety wrote:
>
> Exactamundo! Thanks so much--you've saved me from my very bad mood. I had
> tried the "period" before "Rows("3:3").Copy" and that didn't work, but the
> ".rows(3).Copy" worked wonderfully! Why is that? What's the difference?
> --
> Thanks,
> PTweety
>
> "Dave Peterson" wrote:
>
> > My first guess is this is the line causing trouble:
> >
> > Rows("3:3").Copy
> >
> > I'd use:
> >
> > .Rows("3:3").Copy
> >
> > Then it's copying row 3 of wks.
> >
> > Is that what you wanted?
> >
> > Actually, I'd use:
> >
> > .rows(3).copy
> >
> >
> >
> > pickytweety wrote:
> > >
> > > Hi,
> > > I have a macro that scrolls through a list of stores, pulling up data
> > > regarding each particular store.
> > > There are two different summary sheets, Summary1 and Summary2. In each
> > > summary sheet Row 3 references other areas of the workbook and provides
> > > different statistics for the particular store. I need the macro to copy row
> > > 3 in each sheet and paste it as a value to the first blank row after row 6,
> > > then move on to the next store. The store looping is handled in the "other
> > > code" listed below and that seems to be working. The section of code below
> > > isn't copying and pasting as I was hoping. Is there a different way to write
> > > it? Once again, I just want to copy row three (which changes with each
> > > store) and paste it to row 6, 7, 8, 9 ....and so on--keeping in mind that I
> > > need to do it in both summary sheets. Oh...and I'm hoping to get something
> > > that works in both Excel 2003 and Excel 2007.
> > >
> > > 'other code.....
> > > CopyToNext wksSummary
> > > CopyToNext wksSummary2
> > > 'other code
> > >
> > > Sub CopyToNext(wks As Worksheet)
> > >
> > > Dim rngfill As Range
> > >
> > > With wks
> > > .Outline.ShowLevels RowLevels:=2, ColumnLevels:=2
> > > .Calculate
> > > Set rngfill = Nothing
> > > Set rngfill = .Range("A" & .Rows.Count).End(xlUp)
> > > Set rngfill = rngfill.Offset(1, 0)
> > >
> > > Rows("3:3").Copy
> > > rngfill.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
> > > SkipBlanks:=False, Transpose:=False
> > >
> > > rngfill.PasteSpecial Paste:=xlFormats, Operation:=xlNone, _
> > > SkipBlanks:=False, Transpose:=False
> > >
> > > Application.CutCopyMode = False
> > > End With
> > >
> > > End Sub
> > >
> > > --
> > > Thanks,
> > > PTweety

> >
> > --
> >
> > Dave Peterson
> >


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there a revised version of SP2 P.Jayant Windows XP General 3 12th Aug 2005 03:40 AM
n or U Revised ? =?Utf-8?B?Qmxlc3NpbmdzcG9pbnQ=?= Microsoft Excel Worksheet Functions 1 18th Jan 2005 08:43 PM
SVC Host-revised 3 jah711 Windows XP Setup 1 9th Jun 2004 07:19 PM
SVC Host-Revised jah711 Windows XP Setup 2 9th Jun 2004 03:07 AM
sysprep revised Mark Windows XP Setup 0 7th Aug 2003 01:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:27 AM.