PC Review


Reply
Thread Tools Rate Thread

Autofill with Column as a variable

 
 
LuisE
Guest
Posts: n/a
 
      16th Aug 2008
I want to autofill a range of cells from row 3 to 9 in a given column just
like this

Range("B3").Select
Selection.AutoFill Destination:=Range("B3:B9")

When I use a variable the autofill returns an "Autofill method of range
class failed" error. Need help please

Cells(3, LastCol ).Select
Selection.AutoFill Destination:=Range(Cells(3, LastCol), Cells(9, LastCol ))

Thanks in adavance
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      16th Aug 2008
Have you tried

Range("B3:B9")= Range("B3")

--
HTH,
Barb Reinhardt



"LuisE" wrote:

> I want to autofill a range of cells from row 3 to 9 in a given column just
> like this
>
> Range("B3").Select
> Selection.AutoFill Destination:=Range("B3:B9")
>
> When I use a variable the autofill returns an "Autofill method of range
> class failed" error. Need help please
>
> Cells(3, LastCol ).Select
> Selection.AutoFill Destination:=Range(Cells(3, LastCol), Cells(9, LastCol ))
>
> Thanks in adavance

 
Reply With Quote
 
LuisE
Guest
Posts: n/a
 
      17th Aug 2008
Thanks Barb,

I just tried but it doesn't work.

 
Reply With Quote
 
abu abdullah........halsaeed85@gmail.com
Guest
Posts: n/a
 
      17th Aug 2008
Have you tried Just

Range("B3:B9").Select
 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      17th Aug 2008
i usually do something like this:

Sub test()
Dim lastcol As Long
lastcol = 4
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws
.Cells(3, lastcol).AutoFill Destination:=.Range(.Cells(3, lastcol),
_
.Cells(9, lastcol))
End With
End Sub

--


Gary


"LuisE" <(E-Mail Removed)> wrote in message
news:E1252226-4741-44A9-AA50-(E-Mail Removed)...
>I want to autofill a range of cells from row 3 to 9 in a given column just
> like this
>
> Range("B3").Select
> Selection.AutoFill Destination:=Range("B3:B9")
>
> When I use a variable the autofill returns an "Autofill method of range
> class failed" error. Need help please
>
> Cells(3, LastCol ).Select
> Selection.AutoFill Destination:=Range(Cells(3, LastCol), Cells(9, LastCol ))
>
> Thanks in adavance



 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      17th Aug 2008
wordwrap!

Sub test()
Dim lastcol As Long
lastcol = 4
Dim ws As Worksheet
Set ws = Worksheets("Sheet1")
With ws
.Cells(3, lastcol).AutoFill Destination:=.Range(.Cells(3, lastcol),_
.Cells(9, lastcol))
End With
End Sub

--


Gary


"Gary Keramidas" <GKeramidasATmsn.com> wrote in message
news:(E-Mail Removed)...
>i usually do something like this:
>
> Sub test()
> Dim lastcol As Long
> lastcol = 4
> Dim ws As Worksheet
> Set ws = Worksheets("Sheet1")
> With ws
> .Cells(3, lastcol).AutoFill Destination:=.Range(.Cells(3, lastcol),
> _
> .Cells(9, lastcol))
> End With
> End Sub
>
> --
>
>
> Gary
>
>
> "LuisE" <(E-Mail Removed)> wrote in message
> news:E1252226-4741-44A9-AA50-(E-Mail Removed)...
>>I want to autofill a range of cells from row 3 to 9 in a given column just
>> like this
>>
>> Range("B3").Select
>> Selection.AutoFill Destination:=Range("B3:B9")
>>
>> When I use a variable the autofill returns an "Autofill method of range
>> class failed" error. Need help please
>>
>> Cells(3, LastCol ).Select
>> Selection.AutoFill Destination:=Range(Cells(3, LastCol), Cells(9, LastCol ))
>>
>> Thanks in adavance

>
>



 
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
RE: Automating to autofill column B based on column A entry Shane Devenshire Microsoft Excel Misc 0 2nd Dec 2008 10:02 PM
autofill variable lenght column w/ sequential numbers using VBA Billyruben Microsoft Excel Misc 2 28th Nov 2008 01:29 AM
variable column numbers for autofill mattybinv Microsoft Excel Programming 1 8th Dec 2005 01:06 PM
Variable Autofill range Kate Microsoft Excel Programming 2 23rd Feb 2004 09:20 PM
Variable Autofill Range Kate Microsoft Excel Programming 1 23rd Feb 2004 09:12 PM


Features
 

Advertising
 

Newsgroups
 


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