copy from one workbook to another

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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.
 
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.
 
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
 
I willhelp you clean up the command box if we get it to work. You can e-mail
me at (e-mail address removed). I will be leavving work in about 1/2 hour. I
will check my e-mail over the weekend.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top