PC Review


Reply
Thread Tools Rate Thread

Command button failure

 
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      7th Oct 2006
Why does the following fail @ Range("D2").Select

Rum-time error '1004"
Application-defined or object-defined error

If I run the exact same code in a Macro it works fine

Private Sub CommandButton1_Click()

Workbooks.Add
ActiveWorkbook.SaveAs Filename:="TempData.xls"
Windows("testbook.XLS").Activate
Range("D27").Select
Selection.Copy
Windows("TempData.XLS").Activate
Range("D2").Select
ActiveSheet.Paste

End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?S2FyaSBKIEtlaW5vbmVu?=
Guest
Posts: n/a
 
      7th Oct 2006
Hello!

I change one row, and it works me!

Workbooks("TempData.XLS").Sheets(1).Range("D2").Select

Regards Kari J Keinonen
 
Reply With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      7th Oct 2006
When I replace "Windows("TempData.XLS").Activate" with

Workbooks("TempData.XLS").Sheets(1).Range("D2").Select

I get a 1004 "Select method of Range class failed" at this new line

oldjay




"Kari J Keinonen" wrote:

> Hello!
>
> I change one row, and it works me!
>
> Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
>
> Regards Kari J Keinonen

 
Reply With Quote
 
=?Utf-8?B?S2FyaSBKIEtlaW5vbmVu?=
Guest
Posts: n/a
 
      7th Oct 2006
Hy!

I don't replace that row.

Regards Kari J Keinonen

"Oldjay" wrote:

> When I replace "Windows("TempData.XLS").Activate" with
>
> Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
>
> I get a 1004 "Select method of Range class failed" at this new line
>
> oldjay
>
>
>
>
> "Kari J Keinonen" wrote:
>
> > Hello!
> >
> > I change one row, and it works me!
> >
> > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> >
> > Regards Kari J Keinonen

 
Reply With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      7th Oct 2006
What row did you replaced??

"Kari J Keinonen" wrote:

> Hy!
>
> I don't replace that row.
>
> Regards Kari J Keinonen
>
> "Oldjay" wrote:
>
> > When I replace "Windows("TempData.XLS").Activate" with
> >
> > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> >
> > I get a 1004 "Select method of Range class failed" at this new line
> >
> > oldjay
> >
> >
> >
> >
> > "Kari J Keinonen" wrote:
> >
> > > Hello!
> > >
> > > I change one row, and it works me!
> > >
> > > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> > >
> > > Regards Kari J Keinonen

 
Reply With Quote
 
=?Utf-8?B?S2FyaSBKIEtlaW5vbmVu?=
Guest
Posts: n/a
 
      7th Oct 2006
Yeps!

That is my code. I hope that helps you!

'********************************************************'
Private Sub CommandButton1_Click()
Dim Filename As String
Dim TestWB As Workbook

Application.DisplayAlerts = False
Workbooks.Add
ActiveWorkbook.SaveAs Filename:="TempData.xls"
Windows("TestWB.XLS").Activate
Range("D27").Select
Selection.Copy
Windows("TempData.XLS").Activate
' that is fix row
Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Application.DisplayAlerts = True
End Sub
'********************************************************'



"Oldjay" wrote:

> What row did you replaced??
>
> "Kari J Keinonen" wrote:
>
> > Hy!
> >
> > I don't replace that row.
> >
> > Regards Kari J Keinonen
> >
> > "Oldjay" wrote:
> >
> > > When I replace "Windows("TempData.XLS").Activate" with
> > >
> > > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> > >
> > > I get a 1004 "Select method of Range class failed" at this new line
> > >
> > > oldjay
> > >
> > >
> > >
> > >
> > > "Kari J Keinonen" wrote:
> > >
> > > > Hello!
> > > >
> > > > I change one row, and it works me!
> > > >
> > > > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> > > >
> > > > Regards Kari J Keinonen

 
Reply With Quote
 
=?Utf-8?B?T2xkamF5?=
Guest
Posts: n/a
 
      7th Oct 2006
Cool!!
Works great
Thanks
oldjay


"Kari J Keinonen" wrote:

> Yeps!
>
> That is my code. I hope that helps you!
>
> '********************************************************'
> Private Sub CommandButton1_Click()
> Dim Filename As String
> Dim TestWB As Workbook
>
> Application.DisplayAlerts = False
> Workbooks.Add
> ActiveWorkbook.SaveAs Filename:="TempData.xls"
> Windows("TestWB.XLS").Activate
> Range("D27").Select
> Selection.Copy
> Windows("TempData.XLS").Activate
> ' that is fix row
> Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> ActiveSheet.Paste
> Application.CutCopyMode = False
> Application.DisplayAlerts = True
> End Sub
> '********************************************************'
>
>
>
> "Oldjay" wrote:
>
> > What row did you replaced??
> >
> > "Kari J Keinonen" wrote:
> >
> > > Hy!
> > >
> > > I don't replace that row.
> > >
> > > Regards Kari J Keinonen
> > >
> > > "Oldjay" wrote:
> > >
> > > > When I replace "Windows("TempData.XLS").Activate" with
> > > >
> > > > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> > > >
> > > > I get a 1004 "Select method of Range class failed" at this new line
> > > >
> > > > oldjay
> > > >
> > > >
> > > >
> > > >
> > > > "Kari J Keinonen" wrote:
> > > >
> > > > > Hello!
> > > > >
> > > > > I change one row, and it works me!
> > > > >
> > > > > Workbooks("TempData.XLS").Sheets(1).Range("D2").Select
> > > > >
> > > > > Regards Kari J Keinonen

 
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
print command from command button in userform causes double chart Mike Jamesson Microsoft Excel Programming 5 11th Aug 2009 03:42 AM
Deselect Command Button by Selecting another Command Button gmcnaugh Microsoft Excel Programming 3 2nd Sep 2008 05:59 PM
Command Button Pictures Taken from Command Bar Button Icons acx@centrum.cz Microsoft Access Forms 0 2nd Dec 2007 12:23 PM
Command Button Failure... =?Utf-8?B?SGVpZGVsYmVyZw==?= Microsoft Access Forms 3 6th Sep 2006 12:31 AM
Setting A Command Bar Button Picture - Catastrophic Failure Error Whatever Microsoft Outlook Program Addins 1 14th Jul 2006 02:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:46 PM.