PC Review


Reply
Thread Tools Rate Thread

auto fill formula on new rows

 
 
RompStar
Guest
Posts: n/a
 
      5th May 2005
does this look like it would do the job of auto filling the formula to
new rows if I stick it into the sheet code ?

Private Sub Worksheet_SelectionChange2(ByVal Target As Range)
Application.EnableEvents = False
If Target.Offset(-1, 0).HasFormula = True Then
Range(Target.Offset(-1, 0), Target).FillDown
End If
Application.EnableEvents = True
End Sub

I did it and turned off the extend data range formats and formulas in
tools, options and edit...

SO I am thinking the script isn't working like it should, how close is
it ?

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      5th May 2005
First, there is no "Worksheet_SelectionChange2" event. So that means if you
wanted this to run automatically, it won't work. And it would scare me to use
the "worksheet_selectionchange" event--it would fire way too often for me.

Just my opinion, but if I wanted something like this, I'd want to run it on
demand--not automatic.

If that appeals to you, you may want to look at the way David McRitchie handled
it:
http://www.mvps.org/dmcritchie/excel/insrtrow.htm
look for: InsertRowsAndFillFormulas



RompStar wrote:
>
> does this look like it would do the job of auto filling the formula to
> new rows if I stick it into the sheet code ?
>
> Private Sub Worksheet_SelectionChange2(ByVal Target As Range)
> Application.EnableEvents = False
> If Target.Offset(-1, 0).HasFormula = True Then
> Range(Target.Offset(-1, 0), Target).FillDown
> End If
> Application.EnableEvents = True
> End Sub
>
> I did it and turned off the extend data range formats and formulas in
> tools, options and edit...
>
> SO I am thinking the script isn't working like it should, how close is
> it ?


--

Dave Peterson
 
Reply With Quote
 
RompStar
Guest
Posts: n/a
 
      5th May 2005
cool, for now I went with this, only so many things that I can do in an
8 hour work day :- ) wipping me at the office :- ) lol

for now, I solved it like this with some help..

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo Err
Application.EnableEvents = False

If Intersect(Target.Offset(-1, 0),
Cells.SpecialCells(xlCellTypeAllValidation)) Is Nothing Then GoTo Err
Target.Offset(-1, 0).Copy
Target.PasteSpecial Paste:=xlPasteValidation
Application.CutCopyMode = False

Err:
If Target.Column <> 12 Then GoTo ErrEnd
If Target.Offset(-1, 0).HasFormula = True Then
Range(Target.Offset(-1, 0), Target).FillDown
End If

ErrEnd: Application.EnableEvents = True

End Sub

 
Reply With Quote
 
David McRitchie
Guest
Posts: n/a
 
      6th May 2005
There is also a change event macro that I just added a couple of days
ago that you may like better than your selection change macro.
http://www.mvps.org/dmcritchie/excel...m#change_event
You have to do your own insert row, and the macro will be triggered
when you type into column A . If it is the last row then you don't
have to insert, just type into Column A. The macro checks to
make sure the rest of the row is empty otherwise it doesn't continue.
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"RompStar" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> cool, for now I went with this, only so many things that I can do in an
> 8 hour work day :- ) wipping me at the office :- ) lol
>
> for now, I solved it like this with some help..
>
> Private Sub Worksheet_SelectionChange(ByVal Target As Range)
> On Error GoTo Err
> Application.EnableEvents = False
>
> If Intersect(Target.Offset(-1, 0),
> Cells.SpecialCells(xlCellTypeAllValidation)) Is Nothing Then GoTo Err
> Target.Offset(-1, 0).Copy
> Target.PasteSpecial Paste:=xlPasteValidation
> Application.CutCopyMode = False
>
> Err:
> If Target.Column <> 12 Then GoTo ErrEnd
> If Target.Offset(-1, 0).HasFormula = True Then
> Range(Target.Offset(-1, 0), Target).FillDown
> End If
>
> ErrEnd: Application.EnableEvents = True
>
> End Sub
>



 
Reply With Quote
 
RompStar
Guest
Posts: n/a
 
      6th May 2005
Wow, lots of cool free info., thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fill formula down for cells 74 rows apart Reg Microsoft Excel Misc 3 8th Oct 2009 07:28 AM
Auto fill formulae when inserting rows Riker1074 Microsoft Excel Misc 9 30th Dec 2008 04:56 PM
auto fill rows in Excel 2007 billclark54 Microsoft Excel Misc 0 14th Mar 2008 02:54 PM
How to auto fill different rows in the same table =?Utf-8?B?SnVsaWFu?= Microsoft Access Queries 1 26th Jan 2007 04:46 PM
Fill x number of rows with formula =?Utf-8?B?dG91cmxlc3M=?= Microsoft Excel Programming 2 27th Oct 2005 06:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:46 AM.