PC Review


Reply
Thread Tools Rate Thread

Adding/Removing Rows to Referenced Ranged in Worksheet

 
 
Brandon Arnieri
Guest
Posts: n/a
 
      22nd Feb 2008
Hello,

I have an Excel workbook with many worksheets. The first worksheet (Sheet1)
will be need to be referenced in all other worksheets. This has been
straight-forward until i added a new row to the first worksheet. How could I
setup the workbook such that if I change/add/remove row from Sheet1, it will
do the same to the other worksheets without overwriting rows that are
appended below the referencing cells?

Please see example below. Thank you for any help and sorry if the
illustration below is overkill. I just wanted to make it clear as possible.

Brandon

To illustate, I have Sheet1 as follows:

Apple
Boat
Carpet
Dog

And, Sheet2 with cells referencing Sheet1 in parentheses:

(Apple)
(Boat)
(Carpet)
(Dog)
Event
Flag

And, Sheet3 again with cells referencing Sheet1 in parentheses:

(Apple)
(Boat)
(Carpet)
(Dog)
Giraffe
Hippo

Now, if I remove rows in Sheet1 to be:

Apple
Dog

Then, I'd like to have Sheet2 & Sheet3 to be, respectively:

(Apple)
(Dog)
Event
Flag

(Apple)
(Dog)
Giraffe
Hippo

Also, in addition, if I add rows to Sheet1 to be:

Apple
Boat
Carpet
Dog
Elephant

Then, Sheet2 & Sheet3 should be as follows:

(Apple)
(Boat)
(Carpet)
(Dog)
(Elephant)
Event
Flag

(Apple)
(Boat)
(Carpet)
(Dog)
(Elephant)
Giraffe
Hippo




 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      22nd Feb 2008
Rather than talk in terms of deleting rows, I would refer to deleting data.
If I delete Boat and Carpet from sheet one and I want to delete it from all
sheets with all associated data on those rows, it becomes easier.

Sub delredund()
Dim sh As Worksheet, c As Range
For Each sh In ActiveWorkbook.Sheets
Set c = Cells.Find("Boat", LookIn:=xlValues)
If Not c Is Nothing Then
c.EntireRow.Delete
End If
Set c = Cells.Find("Carpet"), LookIn:=xlValues)
If Not c Is Nothing Then
c.EntireRow.Delete
End If
Next
End Sub

Code is untested.


"Brandon Arnieri" wrote:

> Hello,
>
> I have an Excel workbook with many worksheets. The first worksheet (Sheet1)
> will be need to be referenced in all other worksheets. This has been
> straight-forward until i added a new row to the first worksheet. How could I
> setup the workbook such that if I change/add/remove row from Sheet1, it will
> do the same to the other worksheets without overwriting rows that are
> appended below the referencing cells?
>
> Please see example below. Thank you for any help and sorry if the
> illustration below is overkill. I just wanted to make it clear as possible.
>
> Brandon
>
> To illustate, I have Sheet1 as follows:
>
> Apple
> Boat
> Carpet
> Dog
>
> And, Sheet2 with cells referencing Sheet1 in parentheses:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> Event
> Flag
>
> And, Sheet3 again with cells referencing Sheet1 in parentheses:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> Giraffe
> Hippo
>
> Now, if I remove rows in Sheet1 to be:
>
> Apple
> Dog
>
> Then, I'd like to have Sheet2 & Sheet3 to be, respectively:
>
> (Apple)
> (Dog)
> Event
> Flag
>
> (Apple)
> (Dog)
> Giraffe
> Hippo
>
> Also, in addition, if I add rows to Sheet1 to be:
>
> Apple
> Boat
> Carpet
> Dog
> Elephant
>
> Then, Sheet2 & Sheet3 should be as follows:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> (Elephant)
> Event
> Flag
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> (Elephant)
> Giraffe
> Hippo
>
>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      22nd Feb 2008
The addition of rows could be done with a similar loop, you would just have
to tell it where to Insert (and that is the key word) the rows.

"Brandon Arnieri" wrote:

> Hello,
>
> I have an Excel workbook with many worksheets. The first worksheet (Sheet1)
> will be need to be referenced in all other worksheets. This has been
> straight-forward until i added a new row to the first worksheet. How could I
> setup the workbook such that if I change/add/remove row from Sheet1, it will
> do the same to the other worksheets without overwriting rows that are
> appended below the referencing cells?
>
> Please see example below. Thank you for any help and sorry if the
> illustration below is overkill. I just wanted to make it clear as possible.
>
> Brandon
>
> To illustate, I have Sheet1 as follows:
>
> Apple
> Boat
> Carpet
> Dog
>
> And, Sheet2 with cells referencing Sheet1 in parentheses:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> Event
> Flag
>
> And, Sheet3 again with cells referencing Sheet1 in parentheses:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> Giraffe
> Hippo
>
> Now, if I remove rows in Sheet1 to be:
>
> Apple
> Dog
>
> Then, I'd like to have Sheet2 & Sheet3 to be, respectively:
>
> (Apple)
> (Dog)
> Event
> Flag
>
> (Apple)
> (Dog)
> Giraffe
> Hippo
>
> Also, in addition, if I add rows to Sheet1 to be:
>
> Apple
> Boat
> Carpet
> Dog
> Elephant
>
> Then, Sheet2 & Sheet3 should be as follows:
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> (Elephant)
> Event
> Flag
>
> (Apple)
> (Boat)
> (Carpet)
> (Dog)
> (Elephant)
> Giraffe
> Hippo
>
>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      22nd Feb 2008
Correct typo:

Set c = Cells.Find("Carpet", LookIn:=xlValues)


"JLGWhiz" wrote:

> Rather than talk in terms of deleting rows, I would refer to deleting data.
> If I delete Boat and Carpet from sheet one and I want to delete it from all
> sheets with all associated data on those rows, it becomes easier.
>
> Sub delredund()
> Dim sh As Worksheet, c As Range
> For Each sh In ActiveWorkbook.Sheets
> Set c = Cells.Find("Boat", LookIn:=xlValues)
> If Not c Is Nothing Then
> c.EntireRow.Delete
> End If
> Set c = Cells.Find("Carpet"), LookIn:=xlValues)
> If Not c Is Nothing Then
> c.EntireRow.Delete
> End If
> Next
> End Sub
>
> Code is untested.
>
>
> "Brandon Arnieri" wrote:
>
> > Hello,
> >
> > I have an Excel workbook with many worksheets. The first worksheet (Sheet1)
> > will be need to be referenced in all other worksheets. This has been
> > straight-forward until i added a new row to the first worksheet. How could I
> > setup the workbook such that if I change/add/remove row from Sheet1, it will
> > do the same to the other worksheets without overwriting rows that are
> > appended below the referencing cells?
> >
> > Please see example below. Thank you for any help and sorry if the
> > illustration below is overkill. I just wanted to make it clear as possible.
> >
> > Brandon
> >
> > To illustate, I have Sheet1 as follows:
> >
> > Apple
> > Boat
> > Carpet
> > Dog
> >
> > And, Sheet2 with cells referencing Sheet1 in parentheses:
> >
> > (Apple)
> > (Boat)
> > (Carpet)
> > (Dog)
> > Event
> > Flag
> >
> > And, Sheet3 again with cells referencing Sheet1 in parentheses:
> >
> > (Apple)
> > (Boat)
> > (Carpet)
> > (Dog)
> > Giraffe
> > Hippo
> >
> > Now, if I remove rows in Sheet1 to be:
> >
> > Apple
> > Dog
> >
> > Then, I'd like to have Sheet2 & Sheet3 to be, respectively:
> >
> > (Apple)
> > (Dog)
> > Event
> > Flag
> >
> > (Apple)
> > (Dog)
> > Giraffe
> > Hippo
> >
> > Also, in addition, if I add rows to Sheet1 to be:
> >
> > Apple
> > Boat
> > Carpet
> > Dog
> > Elephant
> >
> > Then, Sheet2 & Sheet3 should be as follows:
> >
> > (Apple)
> > (Boat)
> > (Carpet)
> > (Dog)
> > (Elephant)
> > Event
> > Flag
> >
> > (Apple)
> > (Boat)
> > (Carpet)
> > (Dog)
> > (Elephant)
> > Giraffe
> > Hippo
> >
> >
> >
> >

 
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
Adding or removing rows Chris Microsoft Excel Misc 12 10th Jan 2010 12:48 PM
removing specific rows in a worksheet Louise Microsoft Excel Misc 8 22nd Jan 2009 05:50 PM
Automatically Adding Time based on a name ranged Cathy Microsoft Excel Misc 1 27th Feb 2008 02:13 AM
Adding Named ranged for each column... robert.hatcher@l-3com.com Microsoft Excel Programming 2 1st Dec 2006 03:30 AM
Removing blank rows in a worksheet =?Utf-8?B?TG91aXNl?= Microsoft Excel Worksheet Functions 4 26th May 2005 02:21 PM


Features
 

Advertising
 

Newsgroups
 


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