PDA

View Full Version : May you fix this code ?



Nader
01-21-2008, 10:04 AM
First code:
This code is to print the data successively


RowCount = 6
Do Until IsEmpty(Cells(RowCount, 4))
RowCount = RowCount + 1
Loop
Cells(RowCount, 4) = TextBox1.Text

Second code:
I tried this code to delet the data successively, starting from the last data I inserted from the previous code
it menas if I inserted from the first code this data successively George > john > Tom.
the second code will delet starting from the Tom > John > george


RowCount = 'start from the last cell including value(not empty)
Do Until IsNull(Cells(RowCount, 4))
RowCount = RowCount - 1
Loop
Cells(RowCount, 4).Value = "" ' to delet the


But it didn't success with me may you help

http://www.xtremevbtalk.com/x_images/images/misc/progress.gif

Simon Lloyd
01-21-2008, 10:26 AM
Try something like this:

Sub delete_Rows()
Dim i As Integer
Dim Rcount As Integer
Rcount = Range("D65536").End(xlUp).Row
For i = Rcount To 1 Step -1
'YOUR CONDITION HERE
Rows(i).EntireRow.Delete
'END YOUR CONDITION
Next i
End Sub

Nader
01-22-2008, 07:53 AM
It delet all the rows up to last row

this code it delet rows step by step evey time I relase the sub
Dim i As Integer
Dim Rcount As Integer
Rcount = Range("d100").End(xlUp).Row
i = Rcount - 1
Cells(i + 1, 4).Value = ""

Thank youfor

Nader
01-22-2008, 07:53 AM
It delet all the rows up to last row

this code it delet rows step by step evey time I relase the sub
Dim i As Integer
Dim Rcount As Integer
Rcount = Range("d100").End(xlUp).Row
i = Rcount - 1
Cells(i + 1, 4).Value = ""

Thank

Nader
01-22-2008, 07:56 AM
Your code it delets all the rows not step by step

here is the code it delet the rows step by step, every time I realse the sub it delet row.
Dim i As Integer
Dim Rcount As Integer
Rcount = Range("d100").End(xlUp).Row
i = Rcount - 1
Cells(i + 1, 4).Value = ""