Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
data, sort option is grayed. how to sort on a column? | Excel Discussion (Misc queries) | |||
Pls. reply Sort Data and copy to next coulmn when sort order chang | Excel Programming | |||
Sort Data and copy to next coulmn when sort data changes | Excel Programming | |||
Sort Data and copy to next coulmn when sort data changes | Excel Programming | |||
How do I sort a column of data and have each data row sort accordi | Excel Discussion (Misc queries) |