ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Another simple error... (https://www.excelbanter.com/excel-programming/323078-another-simple-error.html)

Jim Berglund

Another simple error...
 
I created the following code, and get 1004 errors. Could you please explain why?

Sheets("Power Units").Activate
With ActiveSheet
.Range("A3:AV3").Select
.Selection.AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault

Range(Cells(4, 1), Cells((response - 2) * 0.4, 48)).Select
Selection.Copy
End With

I've tried it with the "."'s all over, wihtout success. I guess I don't know why these errors occur - It seems a bit arbitrary when they occur.

Thanks in advance...

Jim Berglund

Bob Phillips[_6_]

Another simple error...
 
How about this

With Sheets("Power Units")
.Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), _
Type:=xlFillDefault
.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)).Copy
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim Berglund" wrote in message news:iQ4Qd.388530$6l.283192@pd7tw2no...
I created the following code, and get 1004 errors. Could you please explain why?

Sheets("Power Units").Activate
With ActiveSheet
.Range("A3:AV3").Select
.Selection.AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault

Range(Cells(4, 1), Cells((response - 2) * 0.4, 48)).Select
Selection.Copy
End With

I've tried it with the "."'s all over, wihtout success. I guess I don't know why these errors occur - It seems a bit arbitrary when they occur.

Thanks in advance...

Jim Berglund

Jim Thomlinson[_3_]

Another simple error...
 
What is your code supposed to do? I assume response is a variable? Where does
it come from and what type is it? It definitely will not run in its current
form, but until I know what it is intended to do I really can't help...

"Jim Berglund" wrote:

I created the following code, and get 1004 errors. Could you please explain why?

Sheets("Power Units").Activate
With ActiveSheet
.Range("A3:AV3").Select
.Selection.AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault

Range(Cells(4, 1), Cells((response - 2) * 0.4, 48)).Select
Selection.Copy
End With

I've tried it with the "."'s all over, wihtout success. I guess I don't know why these errors occur - It seems a bit arbitrary when they occur.

Thanks in advance...

Jim Berglund


Jim Berglund

Another simple error...
 
Thanks, Bob. I plugged it in, but still no joy!

I get a 1004 error on the Purple line ( .Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault)

Here's the complete code.

Private Sub CommandButton1_Click()
Dim response
Dim newWO, i, j As Integer


response = InputBox("Enter the number of WO's you want to create")

ScreenUpdating = False

With Sheets("Power Units")
.Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), _
Type:=xlFillDefault
.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)).Copy
End With

...

End Sub
"Bob Phillips" wrote in message ...
How about this

With Sheets("Power Units")
.Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), _
Type:=xlFillDefault
.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)).Copy
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim Berglund" wrote in message news:iQ4Qd.388530$6l.283192@pd7tw2no...
I created the following code, and get 1004 errors. Could you please explain why?

Sheets("Power Units").Activate
With ActiveSheet
.Range("A3:AV3").Select
.Selection.AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault

Range(Cells(4, 1), Cells((response - 2) * 0.4, 48)).Select
Selection.Copy
End With

I've tried it with the "."'s all over, wihtout success. I guess I don't know why these errors occur - It seems a bit arbitrary when they occur.

Thanks in advance...

Jim Berglund

Bob Phillips[_6_]

Another simple error...
 
Jim,

There seem to be 2 problems with the code.

One is that when using autofil, the destination range must include the copy range. The second is that a cell address cannot be a part number, so the *0.4 looks suspect.

This works, but I am not sure the correct number of rows for your needs

Private Sub CommandButton1_Click()
Dim response
Dim newWO, i, j As Integer
Dim rng As Range

response = InputBox("Enter the number of WO's you want to create")

Application.ScreenUpdating = False

With Sheets("Power Units")
Set rng = .Range("A3:AV3").Resize(response, 48)
.Range("A3:AV3").AutoFill Destination:=rng, Type:=xlFillDefault
rng.Copy
End With

'...

End Sub

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim Berglund" wrote in message news:yd6Qd.388754$8l.352400@pd7tw1no...
Thanks, Bob. I plugged it in, but still no joy!

I get a 1004 error on the Purple line ( .Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault)

Here's the complete code.

Private Sub CommandButton1_Click()
Dim response
Dim newWO, i, j As Integer


response = InputBox("Enter the number of WO's you want to create")

ScreenUpdating = False

With Sheets("Power Units")
.Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), _
Type:=xlFillDefault
.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)).Copy
End With

...

End Sub
"Bob Phillips" wrote in message ...
How about this

With Sheets("Power Units")
.Range("A3:AV3").AutoFill Destination:=.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)), _
Type:=xlFillDefault
.Range(.Cells(4, 1), .Cells((response - 2) * 0.4, 48)).Copy
End With

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Jim Berglund" wrote in message news:iQ4Qd.388530$6l.283192@pd7tw2no...
I created the following code, and get 1004 errors. Could you please explain why?

Sheets("Power Units").Activate
With ActiveSheet
.Range("A3:AV3").Select
.Selection.AutoFill Destination:=.Range(.Cells(4, 1), ..Cells((response - 2) * 0.4, 48)), Type:=xlFillDefault

Range(Cells(4, 1), Cells((response - 2) * 0.4, 48)).Select
Selection.Copy
End With

I've tried it with the "."'s all over, wihtout success. I guess I don't know why these errors occur - It seems a bit arbitrary when they occur.

Thanks in advance...

Jim Berglund


All times are GMT +1. The time now is 02:25 PM.

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