ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   code not working correctly (https://www.excelbanter.com/excel-programming/390913-code-not-working-correctly.html)

phil-rge-ee

code not working correctly
 
Can anyone tell me why this code is not working? It always gives me a VB
error when it gets to: Range.Select = ("A2:I27")

All I want to do is copy that range from one excel file to another file.

Private Sub CommandButton1_Click()
'phil
ChDir "\\eeroch1nas02\home\CapursoP\Stats\temp"
Workbooks.Open Filename:= _
"\\eeroch1nas02\home\CapursoP\Stats\temp\Agent work share.xls"
Windows("Agent work share.xls").Activate
Sheets("Phil").Select
Range.Select = ("A2:I27")
Selection.Copy
Windows("Agent work share totals template - Version 2.xls").Activate
Sheets("Phil").Select
Range("A2").Select
ActiveSheet.Paste
Range("J2").Select
Windows("Agent work share.xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub


Thanks,
Phil

moon

code not working correctly
 

Try Range.("A2:I27").Select


"phil-rge-ee" schreef in bericht
...
Can anyone tell me why this code is not working? It always gives me a VB
error when it gets to: Range.Select = ("A2:I27")

All I want to do is copy that range from one excel file to another file.

Private Sub CommandButton1_Click()
'phil
ChDir "\\eeroch1nas02\home\CapursoP\Stats\temp"
Workbooks.Open Filename:= _
"\\eeroch1nas02\home\CapursoP\Stats\temp\Agent work share.xls"
Windows("Agent work share.xls").Activate
Sheets("Phil").Select
Range.Select = ("A2:I27")
Selection.Copy
Windows("Agent work share totals template - Version 2.xls").Activate
Sheets("Phil").Select
Range("A2").Select
ActiveSheet.Paste
Range("J2").Select
Windows("Agent work share.xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub


Thanks,
Phil




phil-rge-ee

code not working correctly
 
I tried it and it gives me a syntax error on that line of code.
Phil

"moon" wrote:


Try Range.("A2:I27").Select


"phil-rge-ee" schreef in bericht
...
Can anyone tell me why this code is not working? It always gives me a VB
error when it gets to: Range.Select = ("A2:I27")

All I want to do is copy that range from one excel file to another file.

Private Sub CommandButton1_Click()
'phil
ChDir "\\eeroch1nas02\home\CapursoP\Stats\temp"
Workbooks.Open Filename:= _
"\\eeroch1nas02\home\CapursoP\Stats\temp\Agent work share.xls"
Windows("Agent work share.xls").Activate
Sheets("Phil").Select
Range.Select = ("A2:I27")
Selection.Copy
Windows("Agent work share totals template - Version 2.xls").Activate
Sheets("Phil").Select
Range("A2").Select
ActiveSheet.Paste
Range("J2").Select
Windows("Agent work share.xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub


Thanks,
Phil





Helmut Weber[_2_]

code not working correctly
 
Range("A2:I27").Select

--

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Gord Dibben

code not working correctly
 
Is that I27 as in "eye" or l27 as in "ell" or have you perhaps entered a 1


Gord Dibben MS Excel MVP

On Thu, 7 Jun 2007 12:22:00 -0700, phil-rge-ee
wrote:

I tried it and it gives me a syntax error on that line of code.
Phil

"moon" wrote:


Try Range.("A2:I27").Select


"phil-rge-ee" schreef in bericht
...
Can anyone tell me why this code is not working? It always gives me a VB
error when it gets to: Range.Select = ("A2:I27")

All I want to do is copy that range from one excel file to another file.

Private Sub CommandButton1_Click()
'phil
ChDir "\\eeroch1nas02\home\CapursoP\Stats\temp"
Workbooks.Open Filename:= _
"\\eeroch1nas02\home\CapursoP\Stats\temp\Agent work share.xls"
Windows("Agent work share.xls").Activate
Sheets("Phil").Select
Range.Select = ("A2:I27")
Selection.Copy
Windows("Agent work share totals template - Version 2.xls").Activate
Sheets("Phil").Select
Range("A2").Select
ActiveSheet.Paste
Range("J2").Select
Windows("Agent work share.xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub


Thanks,
Phil






phil-rge-ee

code not working correctly
 
The letter I (eye).

"Gord Dibben" wrote:

Is that I27 as in "eye" or l27 as in "ell" or have you perhaps entered a 1


Gord Dibben MS Excel MVP

On Thu, 7 Jun 2007 12:22:00 -0700, phil-rge-ee
wrote:

I tried it and it gives me a syntax error on that line of code.
Phil

"moon" wrote:


Try Range.("A2:I27").Select


"phil-rge-ee" schreef in bericht
...
Can anyone tell me why this code is not working? It always gives me a VB
error when it gets to: Range.Select = ("A2:I27")

All I want to do is copy that range from one excel file to another file.

Private Sub CommandButton1_Click()
'phil
ChDir "\\eeroch1nas02\home\CapursoP\Stats\temp"
Workbooks.Open Filename:= _
"\\eeroch1nas02\home\CapursoP\Stats\temp\Agent work share.xls"
Windows("Agent work share.xls").Activate
Sheets("Phil").Select
Range.Select = ("A2:I27")
Selection.Copy
Windows("Agent work share totals template - Version 2.xls").Activate
Sheets("Phil").Select
Range("A2").Select
ActiveSheet.Paste
Range("J2").Select
Windows("Agent work share.xls").Activate
Application.CutCopyMode = False
ActiveWindow.Close
End Sub


Thanks,
Phil







All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com