Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default multi tab workbook

Working with numerous sheets in one book is new for me so please excuse my
ignorance here. My question is I have this code that deletes all rows on a
sheet that doesn't meet the specific criteria of the text "Assets" in column
B. Now I need to enhance this code for a multi sheet Excel book.

My book has 6 tabs labled Assets1, Assets2, Assets3 and so on. I only want
to keep information in Assets1 with the text "GESA CC" in Column labled
"OrigTbl" which is column D and the text "4-$" in Column C labled "Match".
Then in Assets 2 I only want to keep rows that meet the criteria of " GESACC"
in column D with the text of "GESACC Only". I have many other sheets that I
will be able to code if I just see how I would code these two sheets.

One other question, which is better to load all the records on each
individual sheet and detete from the entire list on each page or just copy
the rows I want with the above criteria from the sheet titled "All REcords".
I appreciate your help. Thanks so much

Sub DeleteRows()
Dim LastRow As Long
Dim RowNdx As Long
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(Cells(RowNdx, "B"), "assets", _
vbTextCompare) < 0 Then
Rows(RowNdx).Delete
End If
Next RowNdx
End sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default multi tab workbook

I think I'd do something like:

Sub DeleteRows2()
Dim LastRow As Long
Dim RowNdx As Long

'do 1st sheet
with worksheets("assets1")
'use column D for assets1
LastRow = .Cells(.Rows.Count, "D").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(.Cells(RowNdx, "D").value, "gesa cc", vbTextCompare) = 0 _
or strcomp(.cells(rowndx,"C").value, "4-$", vbtextcompare) = 0 Then
'at least one failed, maybe both, so delete it
.Rows(RowNdx).Delete
End If
Next RowNdx
end with

'do 2nd sheet
'...

End sub

Notice the "with" statement. Everything that starts with a dot belongs to that
with object (Worksheets("assets1") in this case.)

That includes .cells, and .rows.



JOUIOUI wrote:

Working with numerous sheets in one book is new for me so please excuse my
ignorance here. My question is I have this code that deletes all rows on a
sheet that doesn't meet the specific criteria of the text "Assets" in column
B. Now I need to enhance this code for a multi sheet Excel book.

My book has 6 tabs labled Assets1, Assets2, Assets3 and so on. I only want
to keep information in Assets1 with the text "GESA CC" in Column labled
"OrigTbl" which is column D and the text "4-$" in Column C labled "Match".
Then in Assets 2 I only want to keep rows that meet the criteria of " GESACC"
in column D with the text of "GESACC Only". I have many other sheets that I
will be able to code if I just see how I would code these two sheets.

One other question, which is better to load all the records on each
individual sheet and detete from the entire list on each page or just copy
the rows I want with the above criteria from the sheet titled "All REcords".
I appreciate your help. Thanks so much

Sub DeleteRows()
Dim LastRow As Long
Dim RowNdx As Long
LastRow = Cells(Rows.Count, "B").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If StrComp(Cells(RowNdx, "B"), "assets", _
vbTextCompare) < 0 Then
Rows(RowNdx).Delete
End If
Next RowNdx
End sub


--

Dave Peterson
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
Help with multi sheet workbook Sportinus Excel Worksheet Functions 2 July 10th 08 01:41 PM
Complex Multi-condition, multi-workbook count Heliocracy Excel Discussion (Misc queries) 0 October 4th 07 08:18 PM
Finding the top two in a multi page workbook rmwarde Excel Programming 5 December 11th 05 03:50 PM
multi workbook cell referencing Scot[_2_] Excel Programming 1 May 24th 04 10:19 PM
multi-file open to one workbook drabbacs Excel Programming 1 February 3rd 04 03:26 PM


All times are GMT +1. The time now is 04:43 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"