Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default row (i:j).select

Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default row (i:j).select

Rows("i"&":"&"j").Select


HTH
--
AP

"ina" a écrit dans le message de
ups.com...
Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default row (i:j).select

Think you got confused. That would produce an error. for verfication: In the
immediate window

i = 10
j = 10
? "i"&":"&"j"
i:j
? rows("i"&":"&"j").address
' produced an error
--
Regards,
Tom Ogilvy


"Ardus Petus" wrote:

Rows("i"&":"&"j").Select


HTH
--
AP

"ina" a écrit dans le message de
ups.com...
Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default row (i:j).select

Hi Ina,

instead of:

Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

try this

range(cell.address & ":" & cell2.address).rows.delete shift:=xlup

In case I understood correctly what rows you want to delete, otherwise
fix the range.

Ivan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default row (i:j).select

If he wants to delete the entire row, that wouldn't do it:

Verfied from the immediate window:
set cell = cells(3,1)
set cell2 = cells(8,1)
? range(cell.address & ":" & cell2.address).rows.address
$A$3:$A$8



perhaps you were looking for

range(cell.address & ":" & cell2.address).EntireRow.Delete

although
Range(cell,cell2).EntireRow.Delete

should be more efficient

--
Regards,
Tom Ogilvy


" wrote:

Hi Ina,

instead of:

Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

try this

range(cell.address & ":" & cell2.address).rows.delete shift:=xlup

In case I understood correctly what rows you want to delete, otherwise
fix the range.

Ivan




  #6   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default row (i:j).select

Thanks a lot for this answers, effectively I would like to delete a
duplicate entry in a column.

Ina

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default row (i:j).select

Sub deleteDupsInSortedList()
Dim icol as Long, lastrow as Long

icol = 1
lastrow = cells(rows.count,icol).End(xlup)
for i = lastrow to 2 step -1
if cells(i,1).Value = cells(i-1,icol).Value then
rows(i).Delete
end if
Next i

End Sub

--
Regards,
Tom Ogilvy


"ina" wrote:

Thanks a lot for this answers, effectively I would like to delete a
duplicate entry in a column.

Ina


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default row (i:j).select

try this idea

Sub selectrng()
'Rows("3:6").Select
i = 3
j = 6
Rows(i & ":" & j).Delete Shift:=xlUp
'or
'Range(Cells(i, 1), Cells(j, 1)).EntireRow.Delete Shift:=xlUp
End Sub

--
Don Guillett
SalesAid Software

"ina" wrote in message
ups.com...
Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default row (i:j).select

Rows(i & ":" & j).Select

Usually when deleting rows, it is best to loop from the bottom up.

as you can see, if you deleted i = 2 and j = 3, then you add 1 to each, you
are now at row 3 and 4, but these are really the old 5 and 6 (the old 4 gets
skipped)

If you are deleting duplicate rows in a sorted list

last row = cells(rows.count,1).End(xlup)
for i = lastrow to 1 step -1
if cells(i,1).Value = cells(i-1,1).Value then
rows(i).Delete
end if
Next

You are deleting both rows, so I am not sure exactly what your doing, but
maybe the above will provide some ideas.

--
Regards,
Tom Ogilvy


"ina" wrote:

Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina


  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default row (i:j).select

lastrow should not have had a space and should only loop up to row 2:

lastrow = cells(rows.count,1).End(xlup)
for i = lastrow to 2 step -1
if cells(i,1).Value = cells(i-1,1).Value then
rows(i).Delete
end if
Next

--
Regards,
Tom Ogilvy


"Tom Ogilvy" wrote:

Rows(i & ":" & j).Select

Usually when deleting rows, it is best to loop from the bottom up.

as you can see, if you deleted i = 2 and j = 3, then you add 1 to each, you
are now at row 3 and 4, but these are really the old 5 and 6 (the old 4 gets
skipped)

If you are deleting duplicate rows in a sorted list

last row = cells(rows.count,1).End(xlup)
for i = lastrow to 1 step -1
if cells(i,1).Value = cells(i-1,1).Value then
rows(i).Delete
end if
Next

You are deleting both rows, so I am not sure exactly what your doing, but
maybe the above will provide some ideas.

--
Regards,
Tom Ogilvy


"ina" wrote:

Hello,

I have this piece of code: I would like to input in row.select the
range of the row.

cell = Range("A" + CStr(i)).Value
cell2 = Range("A" + CStr(j)).Value

If (cell) = (cell2) And (cell) < " " Then


Rows("""i + ":" + j""").Select
Selection.Delete Shift:=xlUp

Else

i = i + 1
j = j + 1


End If

I have a problem in rows statement.

Thank you

Ina




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
VBA: Column Select then Data Select then return to cell A1 James C[_2_] Excel Discussion (Misc queries) 3 February 1st 10 11:35 AM
Macro to select cells without a certain value and select a menu it Guy[_2_] Excel Worksheet Functions 9 January 2nd 09 05:21 PM
Using formulas to select cells (Ex: Select every nth cell in a col Lakeview Photographic Services Excel Discussion (Misc queries) 2 March 15th 07 02:17 PM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 5th 05 12:03 AM
In Excel 2000, How do you select the whole of a worksheet (Select. Rascal Excel Discussion (Misc queries) 1 March 4th 05 11:59 PM


All times are GMT +1. The time now is 01:35 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"