Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

Help with insert a row

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Al - 19 Sep 2007 14:38 GMT
I am looking for something that will search col. ,
then check for a value (like the word "Building") , insert
a blank row above it.
Mike H - 19 Sep 2007 14:48 GMT
You don't say which column so this works for Column A
Right click the sheet tab, view code and paste this in

Sub atomic()
For x = Range("A65536").End(xlUp).Row To 1 Step -1
   If Cells(x, 1).Value = "Building" Then
       Cells(x, 1).Select
       Selection.EntireRow.Insert
   End If
Next
End Sub

To make it work for another column change the A to the other letter and the
1 in (x,1) to the column Number (D for example is 4)

Mike

> I am looking for something that will search col. ,
> then check for a value (like the word "Building") , insert
> a blank row above it.
Al - 19 Sep 2007 18:06 GMT
It works very well thank you I made the following modification so that the
user can enter the column they want on the fly:
*************************************************
Dim I As Integer, x As Integer

Message = "Enter column letter only"    ' Set prompt.
Title = "Delete rows of designated cells"    ' Set title.
'Default = "1"    ' Set default.
' Display message, title, and default value.

MyValue = InputBox(Message, Title, Default)

Select Case MyValue
   Case "A", "a"
       I = 1
   Case "B", "b"
       I = 2
   Case "C", "c"
       I = 3
   Case "D", "d"
       I = 4
   Case "E", "e"
       I = 5
   Case "F", "f"
       I = 6
   Case "G", "g"
       I = 7
   Case "H", "h"
       I = 8
End Select

For x = Range(MyValue & "65536").End(xlUp).Row To 1 Step -1
   If Cells(x, I).Value = "Building" Then
       Cells(x, I).Select
       Selection.EntireRow.Insert
   End If
Next
**********************************************************
Let me explain to you what I am trying to accomplish and I would appreciate
if you have a better way to do it, to let me know.
Here is a sample of the data in the spread sheet:
********************************************************
Building  Primate Clinic  CRV($000's)  $603     Building Number 504    GSF  2,455   

Subsystem                             Backlog  2008  2009 2010     2011    2012
j.1. Fire Detection Systems     $8         $0     $0     $0     $0     $0
l.1. Interior Finishes                  $0        $0     $0     $0     $0     $32
************************************************************
Here is what the data means:
Building = column lable, Primate Clinic = value, CRV($000's) = column lable,
$603 is the value, Building Number = column lable, 504 = value, GSF = column
lable, 2,455 = value.

Subsystem, Backlog, 2008, 2009, 2010, 2011, 2012 = column lables
the data below them are their values. this pattern repeats in the spread
sheet. not every building will have 2 subsystems, some may have more rows.

Here is what I am trying to accomplish:

I am only interested in "Building" and "Building Number" as lables to be
moved next to the Subsystem, Backlog, 2008, 2009, 2010, 2011, 2012 lables and
then their values moved next to the values of the other lables so that it
should look like this:
*********************************************************
Building    Building Number Subsystem Backlog  2008  2009 2010   2011  2012
Primate Clinic    504          j.1. Fire...   $8         $0     $0     $0     $0  
 $0
Primate Clinic    504          l.1. Inte...   $0         $0     $0     $0     $0  
 $32
*********************************************************  
the data above is what I want to accomplish eventually, if you have a better
way, I am open. I hope that this is clear and I hope that the format stays
the way I typed it. I really appreciate your help. It will help me a lot to
get this issue
resolved.
thanks again
Al

> You don't say which column so this works for Column A
> Right click the sheet tab, view code and paste this in
[quoted text clipped - 16 lines]
> > then check for a value (like the word "Building") , insert
> > a blank row above it.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.