Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default create blank rows

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default create blank rows

Hi,
The following code looks at last used cell in column A then insert 25 rows
from that point. The Insert should carry thew format of the last row over.

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet

'---- CHANGE HERE -------
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'------------------------

'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default create blank rows

Sebastienm,

That portion works great. Thanks! :)

Is there a way to simply accomplish the other request of assigning the next
sequential # in the 'Work Order' column. See my original message text.

"sebastienm" wrote:

Hi,
The following code looks at last used cell in column A then insert 25 rows
from that point. The Insert should carry thew format of the last row over.

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet

'---- CHANGE HERE -------
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'------------------------

'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default create blank rows

sorry, I had forgotten about that part.
At the end of the macro, add the follwing code:
-- assumes that cell in col A contains a number (ordewred properly)
'----------------------------
'Insert numbers
Set rg = Range(InsertionPoint.offset(-expandBy),InsertionPoint.offset(-1))
set rg=application.intersect(rg,rg.parent.range(colToC heck & ":" &
colToCheck))
rg.formula= "=" & rg.cells(1).offset(-1,0).Address(false,false) & "+1"
rg.copy
rg.pastespecial xlPasteValues
application.cutcopymode=false
'--------------------------------------

Would that work? You may have to adjust a bit this latest code as i haven't
checked it.
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Sebastienm,

That portion works great. Thanks! :)

Is there a way to simply accomplish the other request of assigning the next
sequential # in the 'Work Order' column. See my original message text.

"sebastienm" wrote:

Hi,
The following code looks at last used cell in column A then insert 25 rows
from that point. The Insert should carry thew format of the last row over.

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet

'---- CHANGE HERE -------
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'------------------------

'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default create blank rows

Thanks. Works like a charm!

"sebastienm" wrote:

sorry, I had forgotten about that part.
At the end of the macro, add the follwing code:
-- assumes that cell in col A contains a number (ordewred properly)
'----------------------------
'Insert numbers
Set rg = Range(InsertionPoint.offset(-expandBy),InsertionPoint.offset(-1))
set rg=application.intersect(rg,rg.parent.range(colToC heck & ":" &
colToCheck))
rg.formula= "=" & rg.cells(1).offset(-1,0).Address(false,false) & "+1"
rg.copy
rg.pastespecial xlPasteValues
application.cutcopymode=false
'--------------------------------------

Would that work? You may have to adjust a bit this latest code as i haven't
checked it.
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Sebastienm,

That portion works great. Thanks! :)

Is there a way to simply accomplish the other request of assigning the next
sequential # in the 'Work Order' column. See my original message text.

"sebastienm" wrote:

Hi,
The following code looks at last used cell in column A then insert 25 rows
from that point. The Insert should carry thew format of the last row over.

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet

'---- CHANGE HERE -------
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'------------------------

'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default create blank rows

Sebastienm,

One last thing and then I'll stop bugging you. Column C and Column D
contain formulae which I would like the macro to copy down. I was messing
with the xlfilldefault but with no luck:(

Any ideas?

"Coal Miner" wrote:

Thanks. Works like a charm!

"sebastienm" wrote:

sorry, I had forgotten about that part.
At the end of the macro, add the follwing code:
-- assumes that cell in col A contains a number (ordewred properly)
'----------------------------
'Insert numbers
Set rg = Range(InsertionPoint.offset(-expandBy),InsertionPoint.offset(-1))
set rg=application.intersect(rg,rg.parent.range(colToC heck & ":" &
colToCheck))
rg.formula= "=" & rg.cells(1).offset(-1,0).Address(false,false) & "+1"
rg.copy
rg.pastespecial xlPasteValues
application.cutcopymode=false
'--------------------------------------

Would that work? You may have to adjust a bit this latest code as i haven't
checked it.
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Sebastienm,

That portion works great. Thanks! :)

Is there a way to simply accomplish the other request of assigning the next
sequential # in the 'Work Order' column. See my original message text.

"sebastienm" wrote:

Hi,
The following code looks at last used cell in column A then insert 25 rows
from that point. The Insert should carry thew format of the last row over.

Sub test()
Dim InsertionPoint As Range, rg As Range
Dim colToCheck As String
Dim expandBy As Long
Dim wsh As Worksheet

'---- CHANGE HERE -------
Set wsh = ActiveSheet
colToCheck = "A"
expandBy = 25
'------------------------

'Find last currently used row in column colToCheck
Set InsertionPoint = wsh.Range(colToCheck & 65536).End(xlUp).Offset(1,
0).EntireRow

'Insert rows
Set rg = InsertionPoint.Resize(expandBy)
rg.Insert
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"Coal Miner" wrote:

Column 'B' on my worksheet is labeled 'Work Order'. Each row, therefore,
will contain data related to that 'Work Order' #. I would like to create a
macro which will allow the user to hit a button which will add 25 rows to the
worksheet. The rows will be blank other than I would like it to assign the
next consecutive work order # (i.e. if we say we have 100 work orders
assigned, I would like to add 25 rows with work order #'s 101-125). It would
be nice if this code would also somehow copy the formatting of the row. Any
ideas out there??

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
How do I delete blank rows (rows alternate data, blank, data, etc ncochrax Excel Discussion (Misc queries) 2 June 27th 07 04:40 AM
How do I create a Macro to sort data and insert blank rows & subto karinmpfa Excel Worksheet Functions 2 April 25th 06 09:57 PM
Can I create a macro to identify and delete blank rows in a range? carlsondj Excel Programming 6 June 10th 05 12:38 AM
Delete blank row only if 2 consecutive blank rows Amy Excel Programming 2 October 21st 04 05:24 PM
Copying and pasting a worksheet to a blank and removing blank rows Bob Reynolds[_3_] Excel Programming 0 June 24th 04 02:55 PM


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