PC Review


Reply
Thread Tools Rate Thread

Autofill Formula

 
 
Thanks
Guest
Posts: n/a
 
      24th Mar 2010
I am getting a "Method Range of Object Global Failed with this code. What am
I doing wrong?

Dim MyRangeA As Range
Dim LastRowA As Long

Range("J14").Select
LastRowA = Cells(Cells.Rows.Count, "J").End(xlUp).Row
Set MyRangeA = Range("J" & ActiveCell.Row & ":J" & LastRowA - 4)
ActiveCell.FormulaR1C1 = "=MID(R3C2,2,10)"
Range("j14").AutoFill Range("MyRangeA")

End Sub
 
Reply With Quote
 
 
 
 
Rick Rothstein
Guest
Posts: n/a
 
      24th Mar 2010
I didn't test your code and you didn't tell us which line failed, but I'm
guessing it was the last line. Just looking quickly... MyRangeA was declared
as a Range variable and you Set a range into it, so why are you encasing
that Range variable name within quote marks and a encasing that within a
Range call? Wouldn't this be what you want...

Range("j14").AutoFill MyRangeA

since MyRangeA is already a Range?

--
Rick (MVP - Excel)



"Thanks" <(E-Mail Removed)> wrote in message
news:A96FC65D-1F28-4936-B35D-(E-Mail Removed)...
> I am getting a "Method Range of Object Global Failed with this code. What
> am
> I doing wrong?
>
> Dim MyRangeA As Range
> Dim LastRowA As Long
>
> Range("J14").Select
> LastRowA = Cells(Cells.Rows.Count, "J").End(xlUp).Row
> Set MyRangeA = Range("J" & ActiveCell.Row & ":J" & LastRowA - 4)
> ActiveCell.FormulaR1C1 = "=MID(R3C2,2,10)"
> Range("j14").AutoFill Range("MyRangeA")
>
> End Sub


 
Reply With Quote
 
Thanks
Guest
Posts: n/a
 
      24th Mar 2010
Yes thats it


"Rick Rothstein" wrote:

> I didn't test your code and you didn't tell us which line failed, but I'm
> guessing it was the last line. Just looking quickly... MyRangeA was declared
> as a Range variable and you Set a range into it, so why are you encasing
> that Range variable name within quote marks and a encasing that within a
> Range call? Wouldn't this be what you want...
>
> Range("j14").AutoFill MyRangeA
>
> since MyRangeA is already a Range?
>
> --
> Rick (MVP - Excel)
>
>
>
> "Thanks" <(E-Mail Removed)> wrote in message
> news:A96FC65D-1F28-4936-B35D-(E-Mail Removed)...
> > I am getting a "Method Range of Object Global Failed with this code. What
> > am
> > I doing wrong?
> >
> > Dim MyRangeA As Range
> > Dim LastRowA As Long
> >
> > Range("J14").Select
> > LastRowA = Cells(Cells.Rows.Count, "J").End(xlUp).Row
> > Set MyRangeA = Range("J" & ActiveCell.Row & ":J" & LastRowA - 4)
> > ActiveCell.FormulaR1C1 = "=MID(R3C2,2,10)"
> > Range("j14").AutoFill Range("MyRangeA")
> >
> > End Sub

>
> .
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Autofill Formula =?Utf-8?B?dHJpZmZpZGJvb2s=?= Microsoft Excel Worksheet Functions 6 21st Sep 2006 08:23 AM
Autofill formula to next row =?Utf-8?B?QVNV?= Microsoft Excel Misc 4 12th Sep 2006 11:29 PM
Autofill Formula tqdinh22 Microsoft Excel Misc 1 17th Jul 2006 10:29 PM
Re: how do I autofill within a formula Frank Kabel Microsoft Excel Programming 0 9th Sep 2004 10:29 PM
Formula Help (or autofill) RichC Microsoft Excel Discussion 3 21st Sep 2003 06:10 PM


Features
 

Advertising
 

Newsgroups
 


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