Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Sort out data with VBA

I have a spreadsheet that will very in row count every day. I only want to
keep the rows that contain the text "Assets". This criteria will be in
column B. I have an existing macro that adds the page formatting. Can I add
code to this macro to delete everything that does not include Assets in
Column B. Thanks so much.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Sort out data with VBA

Try something like

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



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JOUIOUI" wrote in message
...
I have a spreadsheet that will very in row count every day. I
only want to
keep the rows that contain the text "Assets". This criteria
will be in
column B. I have an existing macro that adds the page
formatting. Can I add
code to this macro to delete everything that does not include
Assets in
Column B. Thanks so much.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Sort out data with VBA

Thanks Chip, this looks like it would work for me but I get this Compile
Error, " Expected Line Number or label statement or end statement". I'm not
sure what this means. Did I so something wrong, I did a straight copy and
paste into my existing macro

"Chip Pearson" wrote:

Try something like

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



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JOUIOUI" wrote in message
...
I have a spreadsheet that will very in row count every day. I
only want to
keep the rows that contain the text "Assets". This criteria
will be in
column B. I have an existing macro that adds the page
formatting. Can I add
code to this macro to delete everything that does not include
Assets in
Column B. Thanks so much.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Sort out data with VBA

Might have been a wordwrap problem:

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

--
Regards,
Tom Ogilvy


"JOUIOUI" wrote:

Thanks Chip, this looks like it would work for me but I get this Compile
Error, " Expected Line Number or label statement or end statement". I'm not
sure what this means. Did I so something wrong, I did a straight copy and
paste into my existing macro

"Chip Pearson" wrote:

Try something like

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



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"JOUIOUI" wrote in message
...
I have a spreadsheet that will very in row count every day. I
only want to
keep the rows that contain the text "Assets". This criteria
will be in
column B. I have an existing macro that adds the page
formatting. Can I add
code to this macro to delete everything that does not include
Assets in
Column B. Thanks so much.




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
data, sort option is grayed. how to sort on a column? Steve Richter Excel Discussion (Misc queries) 1 September 25th 07 03:25 PM
Pls. reply Sort Data and copy to next coulmn when sort order chang shital shah Excel Programming 1 August 19th 05 02:51 PM
Sort Data and copy to next coulmn when sort data changes shital shah Excel Programming 0 August 18th 05 02:55 PM
Sort Data and copy to next coulmn when sort data changes shital shah Excel Programming 0 August 18th 05 06:48 AM
How do I sort a column of data and have each data row sort accordi Oedalis Excel Discussion (Misc queries) 1 March 17th 05 11:52 PM


All times are GMT +1. The time now is 11:19 PM.

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"