Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autofill method of range class failed 1

Status
Not open for further replies.

JPeters

MIS
Jul 25, 2001
423
US
Only getting this error if the number of lines I need pasted is less than 2. Otherwise it works like a charm.

Here's my code:
Range("AT2").Select
ActiveCell.Formula = "=('RF Engineer Only'!$M$1)"
Range("AT2").Select
'Debug.Print "Cell: AT" & RFTabCnt + 1
Selection.AutoFill Destination:=Range("AT2:AT" & RFTabCnt + 1)

When I only want to paste one line that error pops up on the Slection.Autofill line.

I've tried an if statement for RFTabCnt > 1, and I get a similar error if I try to narrow the Destination range to just "AT2" ...

Any clues?

------------------
'How to Keep Your Databases from becoming Overwhelming!' thread181-293590
joshua.peters@attws.com
------------------
 
I read over it and I feel the need to clarify real quick... what I mean is when the Destination Range is AT2:AT2, I get the error. Otherwise it works fine... the range is AT2:ATX (X>1)

Thanks,
Josh

------------------
'How to Keep Your Databases from becoming Overwhelming!' thread181-293590
joshua.peters@attws.com
------------------
 
JP,
Code:
 if RFTabCnt >2 then
   Range("AT2").Formula = "=('RF Engineer Only'!$M$1)"
   'Debug.Print "Cell: AT" & RFTabCnt + 1
   Range("AT2").AutoFill Destination:=Range("AT2:AT" & RFTabCnt + 1)
  end if


Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
Skip,

Apprecaite the advice, but I still need the code to run even when there is only one Cell being pasted (Range AT2:AT2 - just 1 cell) - this is when I get the error. Otherwise I'm sittin pretty.

The RFTabCnt is the RF Worksheet row count, and I paste the same value into the number RFTabCnt ammount of rows down in the same column in a new worksheet. So when I'm pasting 2 or more rows, no problem at all. HOwever if it is just 1,
Range("AT2:AT" & RFTabCnt + 1) .. which is Range("AT2:AT2") - Which should be just one cell, AT2.
I get an error with the AUtofill.

Does Autofill not like sending it ranges of 1 cell? Is there another method I can use besides AutoFill?

Thanks,
-Josh

------------------
'How to Keep Your Databases from becoming Overwhelming!' thread181-293590
joshua.peters@attws.com
------------------
 
Then pull that statement out!
Code:
 Range("AT2").Formula = "=('RF Engineer Only'!$M$1)"
 if RFTabCnt >2 then
   'Debug.Print "Cell: AT" & RFTabCnt + 1
   Range("AT2").AutoFill Destination:=Range("AT2:AT" & RFTabCnt + 1)
  end if


Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
Skip,
Right on. Thanks. I was trying to find out more in depth documentation on how the AutoFill method worked, but you managed to provide me with what I needed. TYVM!

-Josh

------------------
'How to Keep Your Databases from becoming Overwhelming!' thread181-293590
joshua.peters@attws.com
------------------
 
Josh,

It's like the guy that goes to the doctor and says, "Doc, my head hurts after I hit it with a hammer. What can I do?"

And the doctor replys, "Stop hitting your head with a hammer! That will be $80."

Skip,
[sub]
[red]Be advised:[/red] [glasses]
Alcohol and Calculus do not mix!
If you drink, don't derive! [tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top