PC Review


Reply
Thread Tools Rate Thread

Copy varaible no. of rows to another woorkbook

 
 
Jock
Guest
Posts: n/a
 
      5th May 2010
The following should work but it only copies cell A1 from the SSh (source) to
cell A1 on the DSh (destination).

Sub MoveData()

Dim SSh As Worksheet 'source sheet
Dim DSh As Worksheet 'target sheet
Dim LastRow As Long
Dim CopyRange As String

Set SSh = ActiveWorkbook.ActiveSheet
Set DSh = Workbooks("CMS Register of ClaimsAuto").Worksheets("Summary")

CopyRange = SSh.Range("A2:E" & Rows.count).End(xlUp).Copy

DSh.Range("A" & LastRow + 1).PasteSpecial (xlPasteValues)
End Sub

Where did I go wrong?

--
Traa Dy Liooar

Jock
 
Reply With Quote
 
 
 
 
Mike H
Guest
Posts: n/a
 
      5th May 2010
Jock,

Try this

Sub MoveData()

Dim SSh As Worksheet 'source sheet
Dim DSh As Worksheet 'target sheet
Dim LastRow As Long
Dim CopyRange As String
Set SSh = ActiveWorkbook.ActiveSheet
Set DSh = Workbooks("CMS Register of ClaimsAuto.xlsx").Worksheets("Summary")
LastRow = SSh.Cells(Cells.Rows.Count, "E").End(xlUp).Row
SSh.Range("A2:E" & LastRow).Copy
LastRow = DSh.Cells(Cells.Rows.Count, "A").End(xlUp).Row
DSh.Range("A" & LastRow + 1).PasteSpecial (xlPasteValues)
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"Jock" wrote:

> The following should work but it only copies cell A1 from the SSh (source) to
> cell A1 on the DSh (destination).
>
> Sub MoveData()
>
> Dim SSh As Worksheet 'source sheet
> Dim DSh As Worksheet 'target sheet
> Dim LastRow As Long
> Dim CopyRange As String
>
> Set SSh = ActiveWorkbook.ActiveSheet
> Set DSh = Workbooks("CMS Register of ClaimsAuto").Worksheets("Summary")
>
> CopyRange = SSh.Range("A2:E" & Rows.count).End(xlUp).Copy
>
> DSh.Range("A" & LastRow + 1).PasteSpecial (xlPasteValues)
> End Sub
>
> Where did I go wrong?
>
> --
> Traa Dy Liooar
>
> Jock

 
Reply With Quote
 
Jock
Guest
Posts: n/a
 
      6th May 2010
Almost perfect.
This procedure will copy bold text from the source sheet to the destination
sheet. Just prior to that happening, I need all text on the Dest sht from row
4 onwards to be bold = False. How would that be done?
--
Traa Dy Liooar

Jock


"Mike H" wrote:

> Jock,
>
> Try this
>
> Sub MoveData()
>
> Dim SSh As Worksheet 'source sheet
> Dim DSh As Worksheet 'target sheet
> Dim LastRow As Long
> Dim CopyRange As String
> Set SSh = ActiveWorkbook.ActiveSheet
> Set DSh = Workbooks("CMS Register of ClaimsAuto.xlsx").Worksheets("Summary")
> LastRow = SSh.Cells(Cells.Rows.Count, "E").End(xlUp).Row
> SSh.Range("A2:E" & LastRow).Copy
> LastRow = DSh.Cells(Cells.Rows.Count, "A").End(xlUp).Row
> DSh.Range("A" & LastRow + 1).PasteSpecial (xlPasteValues)
> End Sub
>
> --
> Mike
>
> When competing hypotheses are otherwise equal, adopt the hypothesis that
> introduces the fewest assumptions while still sufficiently answering the
> question.
>
>
> "Jock" wrote:
>
> > The following should work but it only copies cell A1 from the SSh (source) to
> > cell A1 on the DSh (destination).
> >
> > Sub MoveData()
> >
> > Dim SSh As Worksheet 'source sheet
> > Dim DSh As Worksheet 'target sheet
> > Dim LastRow As Long
> > Dim CopyRange As String
> >
> > Set SSh = ActiveWorkbook.ActiveSheet
> > Set DSh = Workbooks("CMS Register of ClaimsAuto").Worksheets("Summary")
> >
> > CopyRange = SSh.Range("A2:E" & Rows.count).End(xlUp).Copy
> >
> > DSh.Range("A" & LastRow + 1).PasteSpecial (xlPasteValues)
> > End Sub
> >
> > Where did I go wrong?
> >
> > --
> > Traa Dy Liooar
> >
> > Jock

 
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
Copy pasting Rows, but need to Delete any Shapes/Pictures that are within copied rows Corey Microsoft Excel Programming 2 1st Aug 2007 02:02 AM
Copy rows of data (eliminating blank rows) from fixed layout =?Utf-8?B?U3dlZXBlYQ==?= Microsoft Excel Misc 1 13th Mar 2007 11:05 PM
Hide Rows - copy and paste only rows that show =?Utf-8?B?QWNjZXNzMTAx?= Microsoft Excel Worksheet Functions 3 1st Mar 2006 12:39 AM
woorkbook =?Utf-8?B?RXh4YWxpcw==?= Microsoft Excel Worksheet Functions 1 19th Aug 2005 12:13 PM
How do I copy rows with hidden rows between without unhiding data. =?Utf-8?B?QmlnZ2llIEo=?= Microsoft Excel Misc 1 11th Oct 2004 08:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:02 PM.