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

Hi,

I need a macro to autofill COLUMN A with a word say YES until the last row
found in COLUMN B.

Right now I have the ff codes:

Sheets("VOUCHER - STEP 2").Select
Range("A5").Select
ActiveCell.FormulaR1C1 = "DEBIT"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Set Voucher2 = Worksheets("VOUCHER - STEP 2")
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:" & LastRow(Voucher2))

It shows an error on the autofill range. THANKS!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Autofill Error

Hi,

Maybe this

Sub Fill_Yes()
Set sht = Sheets("VOUCHER - STEP 2")
LastRow = sht.Cells(Cells.Rows.Count, "B").End(xlUp).Row
sht.Range("A5").Value = "DEBIT"
With sht.Range("A5").Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.ColorIndex = xlAutomatic
End With
sht.Range("A6:A" & LastRow).Value = "Yes"
End Sub

--
Mike

When competing hypotheses are otherwise equal, adopt the hypothesis that
introduces the fewest assumptions while still sufficiently answering the
question.


"ch-d" wrote:

Hi,

I need a macro to autofill COLUMN A with a word say YES until the last row
found in COLUMN B.

Right now I have the ff codes:

Sheets("VOUCHER - STEP 2").Select
Range("A5").Select
ActiveCell.FormulaR1C1 = "DEBIT"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Set Voucher2 = Worksheets("VOUCHER - STEP 2")
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:" & LastRow(Voucher2))

It shows an error on the autofill range. THANKS!

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

You have a lot of unneeded code and selections are rarely needed. The main
problem seems to be with the filldown range. Try something like this code:

Sub FillA5Down()
Dim sht As Worksheet
Set sht = Sheets("VOUCHER - STEP 2")
sht.Range("A5").Value = "DEBIT"
With sht.Range("A5").Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.ColorIndex = xlAutomatic
End With
sht.Range("A5", Range("B5").End(xlDown)).FillDown
End Sub

Mike F
"ch-d" wrote in message
...
Hi,

I need a macro to autofill COLUMN A with a word say YES until the last row
found in COLUMN B.

Right now I have the ff codes:

Sheets("VOUCHER - STEP 2").Select
Range("A5").Select
ActiveCell.FormulaR1C1 = "DEBIT"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Set Voucher2 = Worksheets("VOUCHER - STEP 2")
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:" & LastRow(Voucher2))

It shows an error on the autofill range. THANKS!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Autofill Error

Sub FillA5Down()
Dim sht As Worksheet
Set sht = Sheets("sheet8")
sht.Range("A5").Value = "DEBIT"
With sht.Range("A5").Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.ColorIndex = xlAutomatic
End With
lr = sht.Range("B5").End(xlDown).Row
sht.Range(Cells(5, 1), Cells(lr, 1)).FillDown
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Mike Fogleman" wrote in message
...
You have a lot of unneeded code and selections are rarely needed. The main
problem seems to be with the filldown range. Try something like this code:

Sub FillA5Down()
Dim sht As Worksheet
Set sht = Sheets("VOUCHER - STEP 2")
sht.Range("A5").Value = "DEBIT"
With sht.Range("A5").Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.ColorIndex = xlAutomatic
End With
sht.Range("A5", Range("B5").End(xlDown)).FillDown
End Sub

Mike F
"ch-d" wrote in message
...
Hi,

I need a macro to autofill COLUMN A with a word say YES until the last
row
found in COLUMN B.

Right now I have the ff codes:

Sheets("VOUCHER - STEP 2").Select
Range("A5").Select
ActiveCell.FormulaR1C1 = "DEBIT"
With ActiveCell.Characters(Start:=1, Length:=5).Font
.Name = "Arial"
.FontStyle = "Regular"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Set Voucher2 = Worksheets("VOUCHER - STEP 2")
Range("A5").Select
Selection.AutoFill Destination:=Range("A5:" & LastRow(Voucher2))

It shows an error on the autofill range. THANKS!




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

To Mike H, Mike Fogleman and Don Guillett: THANKS A BUNCH! you guys helped me
alot as always! ;-) THANKS!
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
Error on Autofill Wally Excel Programming 2 November 27th 09 07:41 PM
Error 1004 - Autofill diepvic Excel Programming 3 June 30th 09 08:49 AM
Autofill & On Error Resume Next Dandelo Excel Discussion (Misc queries) 2 August 21st 08 07:14 PM
AutoFill Funtion Error DM Excel Programming 3 October 24th 05 01:17 AM
Autofill Error Edgar Thoemmes[_4_] Excel Programming 2 January 13th 05 02:46 AM


All times are GMT +1. The time now is 12:43 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"