LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 142
Default copying cells from one worksheet to another

I want to copy a range of cells from one worksheet to another worksheet. For
instance sheet1, (a1:a14) copy to sheet2 (a1:a14). If these cells are
already used insert the cells and downshift all other cells. I have a little
code but it overrides the cells and not insert them. This is the code that I
have tried to use.

Sub CreateLinkedSummary()
Dim SNames() As String
Dim myAdd As String
Dim myRange As Range
Dim mySS As Worksheet
Dim i As Integer
Dim SCnt As Integer
Dim myCol As Integer

SCnt = ActiveWindow.SelectedSheets.Count

If SCnt = 1 Then
If MsgBox("Are you sure - only one sheet?", vbYesNo) _
= vbYes Then
GoTo ShtOK
Else
MsgBox "Select the sheets and re-run the macro."
Exit Sub
End If
End If

ShtOK:

ReDim SNames(1 To SCnt)

For i = 1 To SCnt
SNames(i) = ActiveWindow.SelectedSheets(i).Name
Next i

Set myRange = Application.InputBox( _
"Select Range to link from", Type:=8)
myAdd = myRange.Address

Set myRange = Application.InputBox( _
"Select sheet and range to link to.", Type:=8)

Set mySS = myRange.Parent
myCol = myRange(1).Column
Worksheets(SNames(1)).Range(myAdd).Copy
mySS.Select
myRange.Select
mySS.Paste Link:=True

For i = 2 To SCnt
Worksheets(SNames(i)).Range(myAdd).Copy
mySS.Cells(mySS.Rows.Count, myCol).End(xlUp)(2).Select
mySS.Paste Link:=True
Next i

myRange.Select
Application.CutCopyMode = False
End Sub

what am i doing wrong?
 
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
Copying worksheet cells into another worksheet using autofill SunnySD Excel Discussion (Misc queries) 3 September 10th 08 10:32 PM
Copying cells to another worksheet Derrick Salmon Excel Programming 1 December 7th 06 03:47 AM
Copying Worksheet Cells Getting 0's lee Excel Discussion (Misc queries) 2 October 5th 06 11:28 AM
Copying a worksheet witrh protected cells to a new worksheet John Excel Worksheet Functions 2 February 1st 06 02:19 PM
Copying cells from 1 worksheet to another Jeffries' Ex New Users to Excel 1 August 1st 05 08:18 PM


All times are GMT +1. The time now is 02:16 AM.

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"