Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to add rows between cells - new at VBA

I have a spreadsheet at work that contains all the schedules for our
SAP scheduling program. This spreadsheet is used for recovery
procedurs for the specific jobs. The problem with the spreadsheet is
that each schedule has END as it's last line, and the next line is the
name of the next schedule. I would like to add two blank rows between
END and the next schedule name. I have a macro that does a find for
END, and then inserts two rows, but the rows go above the END. As I am
new to VBA (never needed to use it until now, so now I'm trying to self
teach), I'm not sure how to get the rows to go under the END cell.
Also, I'm not sure how to have it work for each END in the spreadsheet,
not just one at a time. Any help would be greatly appreciated!

Joey

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to add rows between cells - new at VBA

activecell.offset(1,0).Resize(2).EntireRow.Insert

--
Regards,
Tom Ogilvy


"jmcnelis" wrote in message
ups.com...
I have a spreadsheet at work that contains all the schedules for our
SAP scheduling program. This spreadsheet is used for recovery
procedurs for the specific jobs. The problem with the spreadsheet is
that each schedule has END as it's last line, and the next line is the
name of the next schedule. I would like to add two blank rows between
END and the next schedule name. I have a macro that does a find for
END, and then inserts two rows, but the rows go above the END. As I am
new to VBA (never needed to use it until now, so now I'm trying to self
teach), I'm not sure how to get the rows to go under the END cell.
Also, I'm not sure how to have it work for each END in the spreadsheet,
not just one at a time. Any help would be greatly appreciated!

Joey



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro to add rows between cells - new at VBA

Thanks a lot for the response, Tom! I appreciate it, and it worked
exactly as I wanted it to. Is there a way to set it up so it will look
for each END in the sheet, or do I have to run the macro manually?
Thanks again!

Joey

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Macro to add rows between cells - new at VBA

Assume END appears in column A.

Sub AddLines()
Dim c as Range, firstAddress as String
With Worksheets(1).Columns(1).Cells
Set c = .Find(What:="end", _
After:=Worksheets(1).Range("A1"), _
lookin:=xlValues, Lookat:=xlPart)
If Not c Is Nothing Then
firstAddress = c.Address
Do
c.offset(1,0).Resize(2).EntireRow.Insert
Set c = .FindNext(c)
Loop While c.Address < firstAddress
End If
End With
End Sub


--
Regards,
Tom Ogilvy



"jmcnelis" wrote in message
oups.com...
Thanks a lot for the response, Tom! I appreciate it, and it worked
exactly as I wanted it to. Is there a way to set it up so it will look
for each END in the sheet, or do I have to run the macro manually?
Thanks again!

Joey



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
Macro to copy cells to rows below [email protected] Excel Discussion (Misc queries) 1 January 20th 06 06:59 PM
Macro to hide rows with empty cells tp58tp Excel Worksheet Functions 2 November 13th 04 02:01 PM
macro - hiding rows given a cells content Greg Stevens Excel Programming 3 October 15th 04 09:25 PM
Macro to copy cells one row up then move down 4 rows & repeat Josef Excel Programming 4 October 5th 04 08:49 PM
Macro to delete rows with text cells zsalleh Excel Programming 8 August 27th 04 12:22 AM


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