Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula for inserting rows

Need formula that will allow a number e.g. 5 to be placed in a cell, which
t\will then insert 5 rows. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default formula for inserting rows

That needs VBA.

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
With Target
If IsNumeric(.Value) Then
.Resize(.Value).EntireRow.Insert
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.




--
HTH

Bob Phillips

"Carol49" wrote in message
...
Need formula that will allow a number e.g. 5 to be placed in a cell, which
t\will then insert 5 rows. Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula for inserting rows



"Carol49" wrote:

Need formula that will allow a number e.g. 5 to be placed in a cell, which
t\will then insert 5 rows. Thanks

Formula is what I am looking for, but I am getting a syntax error in the line
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
I have copied and pasted, should I be doing something else? Thanks
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default formula for inserting rows

Have you inserted it in a worksheet code module as instructed?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Carol49" wrote:

Need formula that will allow a number e.g. 5 to be placed in a cell,

which
t\will then insert 5 rows. Thanks

Formula is what I am looking for, but I am getting a syntax error in the

line
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
I have copied and pasted, should I be doing something else? Thanks



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula for inserting rows



"Bob Phillips" wrote:

Have you inserted it in a worksheet code module as instructed?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Carol49" wrote:

Need formula that will allow a number e.g. 5 to be placed in a cell,

which
t\will then insert 5 rows. Thanks

Formula is what I am looking for, but I am getting a syntax error in the

line
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
I have copied and pasted, should I be doing something else? Thanks



Yes, I am right clicking on sheet tab and clicking on View Code and then pasting in formula. Thgat line always comes up red and when I go to enter in the appropriate cells on the correct sheet I gfet the Compile Error - Syntax Error. Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default formula for inserting rows

I am confused, it is fine here.

You say you pasted the formula. What exactly have you copied in?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Bob Phillips" wrote:

Have you inserted it in a worksheet code module as instructed?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Carol49" wrote:

Need formula that will allow a number e.g. 5 to be placed in a cell,

which
t\will then insert 5 rows. Thanks
Formula is what I am looking for, but I am getting a syntax error in

the
line
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
I have copied and pasted, should I be doing something else? Thanks



Yes, I am right clicking on sheet tab and clicking on View Code and then

pasting in formula. Thgat line always comes up red and when I go to enter
in the appropriate cells on the correct sheet I gfet the Compile Error -
Syntax Error. Thanks


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default formula for inserting rows



"Bob Phillips" wrote:

I am confused, it is fine here.

You say you pasted the formula. What exactly have you copied in?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Bob Phillips" wrote:

Have you inserted it in a worksheet code module as instructed?

--
HTH

Bob Phillips

"Carol49" wrote in message
...


"Carol49" wrote:

Need formula that will allow a number e.g. 5 to be placed in a cell,
which
t\will then insert 5 rows. Thanks
Formula is what I am looking for, but I am getting a syntax error in

the
line
If Not Intersect(Target, Me.Range("A1:A10")) Is Nothing Then
I have copied and pasted, should I be doing something else? Thanks


Yes, I am right clicking on sheet tab and clicking on View Code and then

pasting in formula. Thgat line always comes up red and when I go to enter
in the appropriate cells on the correct sheet I gfet the Compile Error -
Syntax Error. Thanks


I have tried from Private Worksheet.....

also from On Error Go....
and I stop after End Sub
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
Inserting new rows, which contain the formula in the above the new DF Excel Discussion (Misc queries) 5 March 5th 10 08:47 AM
Inserting rows on formula sheet? broop[_11_] Excel Discussion (Misc queries) 3 March 4th 09 08:23 PM
inserting rows where a formula is inuse for that column Rose Setting up and Configuration of Excel 2 March 7th 08 10:38 PM
Inserting rows and having the formula follow workofiction New Users to Excel 1 June 21st 05 04:14 PM
Inserting rows with a formula Norman Jones Excel Programming 0 July 27th 04 06:34 PM


All times are GMT +1. The time now is 12:35 AM.

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"