Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Autofill with Column as a variable

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default Autofill with Column as a variable

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 133
Default Autofill with Column as a variable

Thanks Barb,

I just tried but it doesn't work.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Autofill with Column as a variable

Have you tried Just

Range("B3:B9").Select
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Autofill with Column as a variable

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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Autofill with Column as a variable

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
...
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" wrote in message
...
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
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 variable lenght column w/ sequential numbers using VBA Billyruben Excel Discussion (Misc queries) 2 November 28th 08 01:29 AM
Autofill variable range Basta1980 Excel Programming 2 March 19th 08 10:32 AM
variable column numbers for autofill mattybinv Excel Programming 1 December 8th 05 01:06 PM
Variable Autofill range Kate Excel Programming 2 February 23rd 04 09:20 PM
Variable Autofill Range Kate Excel Programming 1 February 23rd 04 09:12 PM


All times are GMT +1. The time now is 11:36 PM.

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"