Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Autofill Formula

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Autofill Formula

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Autofill Formula

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" wrote in message
...
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
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
Autofill Formula caliberprops Excel Worksheet Functions 1 October 18th 06 03:41 PM
Autofill Formula triffidbook Excel Worksheet Functions 6 September 21st 06 08:23 AM
Autofill formula to next row ASU Excel Discussion (Misc queries) 4 September 12th 06 11:29 PM
Autofill Formula tqdinh22 Excel Discussion (Misc queries) 1 July 17th 06 10:29 PM
how do I autofill within a formula Frank Kabel Excel Programming 0 September 9th 04 10:29 PM


All times are GMT +1. The time now is 04:30 AM.

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

About Us

"It's about Microsoft Excel"