Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
#VALUE Error should be simple fix Mykull Excel Discussion (Misc queries) 4 May 5th 09 11:19 PM
Fix Simple #Div/0! error taxmom Excel Worksheet Functions 4 April 18th 06 06:53 PM
Simple #DIV/0! error AMY Z. Excel Worksheet Functions 2 January 23rd 05 10:25 PM
Cannot trace this simple error Paul Robinson Excel Programming 0 April 1st 04 09:00 AM
Simple INT error? Roger[_7_] Excel Programming 8 October 6th 03 09:19 AM


All times are GMT +1. The time now is 11:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"