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

I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default AutoFill Macro

Use it like this for B1 in Sheet1
Note: it overwrite the data that is in B2:B ?

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default AutoFill Macro

Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default AutoFill Macro

I tried the one:

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub

And I get the following error message:

Autofill method of range class failed.

When I tried:

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

I get the same message, what am I missing?

Thank you.

Richard
Joergen Bondesen wrote:
Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default AutoFill Macro

You have only data in B1 of the sheet named Sheet1

LastRow = .Cells(Rows.Count, "B").End(xlUp).Row

This also find B1 now


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message ups.com...
I tried the one:

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub

And I get the following error message:

Autofill method of range class failed.

When I tried:

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

I get the same message, what am I missing?

Thank you.

Richard
Joergen Bondesen wrote:
Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default AutoFill Macro

Ron,

Not clear on your last message, my macro reads:

Sub test2()
Range("B1").Select
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

Since my data is only in B1, that is what I want to autofill from, I am
missing something basic, what is it?

Ron de Bruin wrote:
You have only data in B1 of the sheet named Sheet1

LastRow = .Cells(Rows.Count, "B").End(xlUp).Row

This also find B1 now


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message ups.com...
I tried the one:

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub

And I get the following error message:

Autofill method of range class failed.

When I tried:

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

I get the same message, what am I missing?

Thank you.

Richard
Joergen Bondesen wrote:
Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default AutoFill Macro

Hi

Since my data is only in B1, that is what I want to autofill from, I am
missing something basic, what is it?


The code is looking for the last row with data in column B
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row


It use that row now to AutoFill

.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault


If you only have data in B1 it try to AutoFill B1 to B1 (error)

You can use another column to look for the last row
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row

Or if you know the last row use that in the code

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = 20
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message oups.com...
Ron,

Not clear on your last message, my macro reads:

Sub test2()
Range("B1").Select
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

Since my data is only in B1, that is what I want to autofill from, I am
missing something basic, what is it?

Ron de Bruin wrote:
You have only data in B1 of the sheet named Sheet1

LastRow = .Cells(Rows.Count, "B").End(xlUp).Row

This also find B1 now


--
Regards Ron de Bruin
http://www.rondebruin.nl



wrote in message ups.com...
I tried the one:

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub

And I get the following error message:

Autofill method of range class failed.

When I tried:

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

I get the same message, what am I missing?

Thank you.

Richard
Joergen Bondesen wrote:
Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard





  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default AutoFill Macro

Hi Richard

Sorry about my bad programming.
I hope below will suits you better. 8-)


Option Explicit

Const Startcell As String = "B1"
Const SheetName As String = "Test1"

'----------------------------------------------------------
' Procedure : FillDown
' Date : 20060819
' Author : Joergen Bondesen
' Modifyed by :
' Purpose : Fill down Startcell to lastrow if Startcell
' < empty.
' Note : Change Const: 'Startcell' and 'SheetName'
'----------------------------------------------------------
'
Sub FillDown()

Dim WS As Worksheet
Dim Srange As Range
Dim Lastrow As Long

Set WS = Worksheets(SheetName)
Set Srange = WS.Range(Startcell)

With WS
'// Empty Startcell
If Srange = vbNullString Then End

'// Lastrow
Lastrow = .Cells(.Rows.Count, _
Srange.Column).End(xlUp).Row
'// Startrow = Lastrow
If Lastrow = Srange.Row Then End

'// Fill down
.Range(Startcell).AutoFill _
Destination:=.Range(.Cells(Srange.Row, _
Srange.Column), _
.Cells(Lastrow, Srange.Column))
End With

Set WS = Nothing
Set Srange = Nothing
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I tried the one:

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row
Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub

And I get the following error message:

Autofill method of range class failed.

When I tried:

Sub test2()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
.Range("B1").AutoFill Destination:=.Range("B1:B" & LastRow) _
, Type:=xlFillDefault
End With
End Sub

I get the same message, what am I missing?

Thank you.

Richard
Joergen Bondesen wrote:
Hi Richard

Try below, please.

Sub test2()

Dim endRow As Long
endRow = Cells(Rows.Count, 2).End(xlUp).Row

Range("B1").Autofill Destination:=Range("B1:B" & endRow)
End Sub


--
Best regards
Joergen Bondesen


wrote in message
ups.com...
I thought that i posted this yesterday but I can't find the posting so
if this is a double post, please point me in the direction of the
original post and I will go from there.

I have the following Code:

Sub Autofill()
'
'
Range("B1").Select
Selection.Copy
Selection.AutoFill Destination:=Range("B1:B10")
Range("B1:B10").Select
Range("G17").Select
End Sub

I looked at previous postings on this group and found this topic
addressed before and I found code on how to do this so I attempted to
apply the following code:

Sub Test()
'
' Test Macro
'
Range("B1").Select
Dim endRow As Long
endRow = Cells(Rows.Count, ("B1:B")).End(xlUp).Row
ActiveCell.AutoFill Destination:=Range("B1:B")
End Sub

However, it keeps errorring out, any suggestions?

Thank you.

Richard




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
HELP!!! I need macro to autofill Joe M. Excel Discussion (Misc queries) 4 February 10th 10 07:32 PM
Autofill in macro orquidea Excel Discussion (Misc queries) 5 November 21st 07 11:20 PM
Autofill Macro Hayabusa Excel Programming 1 November 25th 05 05:47 PM
Autofill macro Mike G Excel Discussion (Misc queries) 6 April 21st 05 01:33 AM
autofill macro glee Excel Discussion (Misc queries) 1 February 14th 05 05:14 PM


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

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"