Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default copy from one workbook to another

Hello people,

Id like to construct a macro that copies all rows from the current worksheet
(copy the whole lenght of the row just as leftclicking the 1st row
number and holding and draging down until the last row with data is
selected would), and then copying it to another workbok, workbook2, sheet2
row2 , just as
rightclicking row 2 and chosing insert copied cells would. any suggestions?

Thank you in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default copy from one workbook to another

I don't know how much experience you have in VBA. If you arre experience
then try these statements

Worksheets(SavedWorksheetName).Activate
PlotRange.RefEditPlotCell.SetFocus
PlotRange.Show
PlotRangeString = PlotRange.RefEditPlotCell.Value

This will puu up a nice pop up window to select cells.

"steven" wrote:

Hello people,

Id like to construct a macro that copies all rows from the current worksheet
(copy the whole lenght of the row just as leftclicking the 1st row
number and holding and draging down until the last row with data is
selected would), and then copying it to another workbok, workbook2, sheet2
row2 , just as
rightclicking row 2 and chosing insert copied cells would. any suggestions?

Thank you in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default copy from one workbook to another

Hi, thanks for your input but i am really not experienced. I tried a little
with the code you gave me but i can't figure it out... can I please have the
actual code if it's not much of a fuss... it the path of the file for the
data to be copied at is a problem lets say its:
C:\Documents and Settings\User\Desktop\b.xls

thanks,

S.

"Joel" wrote:

I don't know how much experience you have in VBA. If you arre experience
then try these statements

Worksheets(SavedWorksheetName).Activate
PlotRange.RefEditPlotCell.SetFocus
PlotRange.Show
PlotRangeString = PlotRange.RefEditPlotCell.Value

This will puu up a nice pop up window to select cells.

"steven" wrote:

Hello people,

Id like to construct a macro that copies all rows from the current worksheet
(copy the whole lenght of the row just as leftclicking the 1st row
number and holding and draging down until the last row with data is
selected would), and then copying it to another workbok, workbook2, sheet2
row2 , just as
rightclicking row 2 and chosing insert copied cells would. any suggestions?

Thank you in advance.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default copy from one workbook to another

It took me a while to gedt the bugs out of the code. Excel is very picky
with the format

You have to set up a user form.
follow these istructions

1) In Visual Basic editor - Insert User form
2)Make sure Standard Toolbar is enabled
3) In standard toolbar select the Wrench and hammer
4) Slide The Reff Edit box and the commmand button into the userform1
5) double click the command button or click right mouser button and view
code. Add to Sub CommandButton1_Click()
UserForm1.Hide
end Sub


Add Code below to a Module


Sub Copy_worksheet()
'
'

'
oldworkbook_name = ActiveWorkbook.Name

Worksheets("Sheet1").Activate
UserForm1.RefEdit1.SetFocus
UserForm1.Show
oldcopyrangeString = UserForm1.RefEdit1.Value


Range(oldcopyrangeString).Select
Selection.Copy

atpfilename = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
Workbooks.Open Filename:=atpfilename

'getworkbook name
Do While (InStr(atpfilename, "\") < 0)
x = InStr(atpfilename, "\")
atpfilename = Mid(atpfilename, InStr(atpfilename, "\") + 1)
Loop



UserForm1.RefEdit1.SetFocus
UserForm1.Show
copyrangeString = UserForm1.RefEdit1.Value

If InStr(copyrangeString, "!") < 0 Then
copyrangeString = Mid(copyrangeString, InStr(copyrangeString, "!") +
1)
End If

Workbooks(oldworkbook_name).Activate
Range(oldcopyrangeString).Select
Selection.Copy

Windows(atpfilename).Activate

Range(copyrangeString).Select

ActiveSheet.Paste



"steven" wrote:

Hello people,

Id like to construct a macro that copies all rows from the current worksheet
(copy the whole lenght of the row just as leftclicking the 1st row
number and holding and draging down until the last row with data is
selected would), and then copying it to another workbok, workbook2, sheet2
row2 , just as
rightclicking row 2 and chosing insert copied cells would. any suggestions?

Thank you in advance.

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
Macro to copy an image (or picture) from one workbook to a new sheetin another workbook Ruchir Excel Worksheet Functions 1 July 25th 08 07:29 AM
Excel-how to link source workbook to copy of destination workbook D Lynn Excel Worksheet Functions 1 May 29th 08 05:36 PM
loop through a column on a workbook copying data on each row to another workbook, then copy data back to the original workbook burl_rfc Excel Programming 1 April 1st 06 08:48 PM
Copy a range of cells in an unopened workbook and paste it to the current workbook topstar Excel Programming 3 June 24th 04 12:50 PM


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

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"