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
|