LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Excel AutoFillOption

Hi,
I have a cell in excel sheet which has both text and Numbers as "Product1".
I want to copy this cell value to the next 10 cells and i have dragged the
auto fill. But the result is it keeps incrementing the number for every next
cell and gives me values product1,product2,product3,...... But i want to copy
Product1 in all cells. I know we can change the option to Copy cells in
autofill but i want to do this through VBA code.
Whenever we drag the autofill, the fill should just copy cells instead of
fill series. How can i do this using VBA?
I have tried the following:

Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Then
Call Drag
End If
End Sub

Module:
Sub Drag()
ActiveCell.AutoFill Destination:=Range(Selection.Address),
Type:=xlFillCopy
End Sub

Its working fine if i want to copy for more than 1 cell. But if i drag just
for the cell below, it doesnt work. It increments again. I tried changing
code to

Target.Cells.Count = 1

But i get an error at line

ActiveCell.AutoFill Destination:=Range(Selection.Address), Type:=xlFillCopy

ANy help on this please???
 
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



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