Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 623
Default Using Autofill knowing row and column number

I want to do the programmatic equivalent of dragging the fill handle down
one row. I know the row and column number of the destination cell. I tried:

..cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)

but I got a range error. What's the correct syntax? Also, what's the syntax
if I want to fill a range of cells (eg, columns 12 to17)?

--
Thanks,
Fred




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using Autofill knowing row and column number

Sub AA()
Dim NextRow As Long
Dim rng As Range
NextRow = 10
With ActiveSheet
Set rng = .Range(.Cells(NextRow - 1, 2), .Cells(NextRow, 2))
.Cells(NextRow - 1, 2).AutoFill Destination:=rng
End With
End Sub

--
Regards,
Tom Ogilvy




"Fred Smith" wrote in message
...
I want to do the programmatic equivalent of dragging the fill handle down
one row. I know the row and column number of the destination cell. I

tried:

.cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)

but I got a range error. What's the correct syntax? Also, what's the

syntax
if I want to fill a range of cells (eg, columns 12 to17)?

--
Thanks,
Fred






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Using Autofill knowing row and column number

How about:

Option Explicit
Sub testme01()
Dim NextRow As Long
NextRow = 3 'test data only
With ActiveSheet
.Cells(NextRow - 1, 2).AutoFill _
Destination:=.Cells(NextRow - 1, 2).Resize(2, 1)
End With
End Sub



Fred Smith wrote:

I want to do the programmatic equivalent of dragging the fill handle down
one row. I know the row and column number of the destination cell. I tried:

.cells(Nextrow - 1, 2).autofill destination=.cells(Nextrow, 2)

but I got a range error. What's the correct syntax? Also, what's the syntax
if I want to fill a range of cells (eg, columns 12 to17)?

--
Thanks,
Fred


--

Dave Peterson
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 column from data (code) in column next to it Matt Excel Worksheet Functions 4 April 24th 09 06:17 PM
Knowing the number sadman49 Excel Discussion (Misc queries) 2 March 9th 09 09:15 PM
Automating to autofill column B based on column A entry GirlFridayCA Excel Discussion (Misc queries) 2 December 2nd 08 10:46 PM
Autofill Column D based on input in Column C Helen McClaine Excel Discussion (Misc queries) 1 April 5th 05 09:11 PM
Number of different items in an entire column without knowing if some of the cells are blank [email protected] Excel Programming 10 March 20th 05 05:31 PM


All times are GMT +1. The time now is 01:18 AM.

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"