Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Data Formatting

Hello All.

In excel, I need to keep the first row when it is followed by other
rows with the first two cells the same.

Therefo

CELLA CELLB CELLC
21 COMPANY TEXT VARIES - keep
21 COMPANY TEXT VARIES - delete
22 COMPANY TEXT VARIES - keep
22 COMPANY TEXT VARIES - delete
22 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - keep
23 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - delete

Make sense?? Please help me.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default Data Formatting

Sub DeleteRows()
Dim iRow As Integer
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
iRow = 1
Do
If ws.Cells(iRow + 1, "A") = ws.Cells(iRow, "A") _
And ws.Cells(iRow + 1, "B") = ws.Cells(iRow, "B") Then
ws.Rows(iRow + 1).Delete
Else
iRow = iRow + 1
End If
Loop Until ws.Cells(iRow + 1, "A") = ""
End Sub

HTH,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Data Formatting

Set currentcell = Range("A1")
do while not isempty(currentCell)
Set nextcell = currentcell.Offset(1,0)
if currentcell.value = nextcell.value then
nextcell.entirerow.delete
Set nextcell = currentcell.offset(1,0)
else
set currentcell = nextcell
end if
loop
-----Original Message-----
Hello All.

In excel, I need to keep the first row when it is

followed by other
rows with the first two cells the same.

Therefo

CELLA CELLB CELLC
21 COMPANY TEXT VARIES - keep
21 COMPANY TEXT VARIES - delete
22 COMPANY TEXT VARIES - keep
22 COMPANY TEXT VARIES - delete
22 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - keep
23 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - delete
23 COMPANY TEXT VARIES - delete

Make sense?? Please help me.
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Data Formatting

Hello.

Using the information below, I am getting the following error "Set ws
= Sheets("Sheet1")". What does that mean?? How do I fix it?

Thank you for all of your help.

"merjet" wrote in message ...
Sub DeleteRows()
Dim iRow As Integer
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
iRow = 1
Do
If ws.Cells(iRow + 1, "A") = ws.Cells(iRow, "A") _
And ws.Cells(iRow + 1, "B") = ws.Cells(iRow, "B") Then
ws.Rows(iRow + 1).Delete
Else
iRow = iRow + 1
End If
Loop Until ws.Cells(iRow + 1, "A") = ""
End Sub

HTH,
Merjet

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Data Formatting

Hi Programmer wanna be,

Perhaps you do not have a sheet named Sheet1.

Try replacing Sheet1 with the name of your sheet.


---
Regards,
Norman



"Programmer wanna be" wrote in message
m...
Hello.

Using the information below, I am getting the following error "Set ws
= Sheets("Sheet1")". What does that mean?? How do I fix it?

Thank you for all of your help.

"merjet" wrote in message

...
Sub DeleteRows()
Dim iRow As Integer
Dim ws As Worksheet
Set ws = Sheets("Sheet1")
iRow = 1
Do
If ws.Cells(iRow + 1, "A") = ws.Cells(iRow, "A") _
And ws.Cells(iRow + 1, "B") = ws.Cells(iRow, "B") Then
ws.Rows(iRow + 1).Delete
Else
iRow = iRow + 1
End If
Loop Until ws.Cells(iRow + 1, "A") = ""
End Sub

HTH,
Merjet



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
Formatting ALL data labels for ALL data series at once Vasco Charts and Charting in Excel 8 April 3rd 23 02:41 PM
Formatting data series - line between certain data points only alan_m Charts and Charting in Excel 0 September 20th 07 05:16 PM
Formatting Rows of Data based on Column Data mwmasch Excel Worksheet Functions 3 July 24th 07 04:36 PM
How can I cut data out of HTML table, into msExcel and just take the data & columns? (but NOT the formatting & URLs!) ship Excel Discussion (Misc queries) 24 April 25th 06 06:02 PM
Formatting data rn Excel Discussion (Misc queries) 1 March 17th 05 10:01 AM


All times are GMT +1. The time now is 01:19 AM.

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

About Us

"It's about Microsoft Excel"