ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Command button failure (https://www.excelbanter.com/excel-programming/374558-command-button-failure.html)

Oldjay

Command button failure
 
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("D2:D7").Select
Selection.Copy
Windows("TempData.XLS").Activate
Range("D2").Select
ActiveSheet.Paste

End Sub


Kari J Keinonen[_2_]

Command button failure
 
Hello!

I change one row, and it works me!

Workbooks("TempData.XLS").Sheets(1).Range("D2").Se lect

Regards Kari J Keinonen

Oldjay

Command button failure
 
When I replace "Windows("TempData.XLS").Activate" with

Workbooks("TempData.XLS").Sheets(1).Range("D2").Se lect

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").Se lect

Regards Kari J Keinonen


Kari J Keinonen[_2_]

Command button failure
 
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").Se lect

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").Se lect

Regards Kari J Keinonen


Oldjay

Command button failure
 
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").Se lect

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").Se lect

Regards Kari J Keinonen



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

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