Blank rows deletion
Closed
Aslam
-
23 Oct 2011 à 16:42
aquarelle Posts 7181 Registration date Saturday 7 April 2007 Status Moderator Last seen 14 February 2026 - 16 Nov 2011 à 00:19
aquarelle Posts 7181 Registration date Saturday 7 April 2007 Status Moderator Last seen 14 February 2026 - 16 Nov 2011 à 00:19
Related:
- Blank rows deletion
- How to delete rows in word - Guide
- How to repeat rows in excel - Guide
- Convert multiple rows to columns in excel macro - Excel Forum
- Computer with blank screen - Guide
- Blank data ✓ - Excel Forum
6 responses
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
23 Oct 2011 à 22:46
23 Oct 2011 à 22:46
copy the data in sheet 1 in some other location e.g. sheet 2 also as precaution
now try this macro on sheet1
now try this macro on sheet1
Sub test()
Dim r As Range, j As Long, r1 As Range
j = Cells(Rows.Count, "A").End(xlUp).Row
Set r = Cells(j, 1)
Do
Set r1 = r.End(xlUp)
Range(r.End(xlUp).Offset(-1, 0), r1.End(xlUp).Offset(2, 0)).EntireRow.Delete
Set r = r1.End(xlUp)
If r.Row = Range("A1").End(xlDown).Row Then Exit Do
Loop
End Sub
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
24 Oct 2011 à 03:13
24 Oct 2011 à 03:13
quote
ust need one amendment in this, that the macro will work only on sheet1 of workbook "Records" not on all open workbooks.
unquote
First save the workbook safely some where to recover if something goes wrong.
see this macro
ust need one amendment in this, that the macro will work only on sheet1 of workbook "Records" not on all open workbooks.
unquote
First save the workbook safely some where to recover if something goes wrong.
see this macro
Sub test()
Dim r As Range, j As Long, r1 As Range, k As Long
For k = 1 To Worksheets.Count
With Worksheets(k)
j = .Cells(Rows.Count, "A").End(xlUp).Row
Set r = .Cells(j, 1)
Do
Set r1 = r.End(xlUp)
Range(r.End(xlUp).Offset(-1, 0), r1.End(xlUp).Offset(2, 0)).EntireRow.Delete
Set r = r1.End(xlUp)
If r.Row = .Range("A1").End(xlDown).Row Then Exit Do
Loop
End With
Next k
End Sub
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
25 Oct 2011 à 20:50
25 Oct 2011 à 20:50
can you please post a very small extract of atleast 2 data sheets
aquarelle
Posts
7181
Registration date
Saturday 7 April 2007
Status
Moderator
Last seen
14 February 2026
491
28 Oct 2011 à 13:55
28 Oct 2011 à 13:55
Hi,
To send an extracted sheets you can upload your file on https://authentification.site and copy/paste the created link into your next message.
Regards
To send an extracted sheets you can upload your file on https://authentification.site and copy/paste the created link into your next message.
Regards
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
29 Oct 2011 à 03:16
29 Oct 2011 à 03:16
take aquarelle'S suggestion
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
11 Nov 2011 à 22:44
11 Nov 2011 à 22:44
thank you for uploading the two files. in your first message you talk about worksheet named "records". there is no such sheet in either of your two files
I suggest re frame your questions with respect to these two files.
I suggest re frame your questions with respect to these two files.
Dear Venkat1926,
I need one blank row after record of each month rest should be deleted, for this purpose I am using following macro but its not working properly:
Public Sub DeleteRow()
' DeleteRow Macro
'
' Keyboard Shortcut: Ctrl+j
Dim x As Long
Dim y As Long
x = Range("C65536").End(xlUp).Row
For y = x To 2 Step -1
If Cells(y, 2).Value = "" And Cells(y, 3).Value = "" And Cells(y, 4).Value = "" Then
Rows(y).Delete
End If
Next y
End Sub
kindly check it and amend it where its needed.
just keep one row blank row after records of each month to make it seperate, rest blank rows should be deleted through macro. The macro should work till last row of the worksheet.
Thank you,
Aslam
I need one blank row after record of each month rest should be deleted, for this purpose I am using following macro but its not working properly:
Public Sub DeleteRow()
' DeleteRow Macro
'
' Keyboard Shortcut: Ctrl+j
Dim x As Long
Dim y As Long
x = Range("C65536").End(xlUp).Row
For y = x To 2 Step -1
If Cells(y, 2).Value = "" And Cells(y, 3).Value = "" And Cells(y, 4).Value = "" Then
Rows(y).Delete
End If
Next y
End Sub
kindly check it and amend it where its needed.
just keep one row blank row after records of each month to make it seperate, rest blank rows should be deleted through macro. The macro should work till last row of the worksheet.
Thank you,
Aslam
venkat1926
Posts
1863
Registration date
Sunday 14 June 2009
Status
Contributor
Last seen
7 August 2021
811
15 Nov 2011 à 20:35
15 Nov 2011 à 20:35
Aslam there appears to be a SPAM reply. inform administrator
however your request
"just keep one row blank row after records of each month to make it seperate, rest blank rows should be deleted through macro. The macro should work till last row of the worksheet. "
try this macro
however your request
"just keep one row blank row after records of each month to make it seperate, rest blank rows should be deleted through macro. The macro should work till last row of the worksheet. "
try this macro
Public Sub DeleteRow()
' DeleteRow Macro
'
' Keyboard Shortcut: Ctrl+j
Dim x As Long
Dim y As Long
x = Range("C65536").End(xlUp).Row
For y = x To 2 Step -1
If Cells(y, 2).Value = "" And Cells(y, 3).Value = "" And Cells(y, 4).Value = "" Then
Rows(y).Delete
End If
Next y
For y = 2 To x
If Cells(y, "B") <> "" Then Rows(y + 1).Insert
Next y
End Sub
aquarelle
Posts
7181
Registration date
Saturday 7 April 2007
Status
Moderator
Last seen
14 February 2026
491
16 Nov 2011 à 00:19
16 Nov 2011 à 00:19
Hi,
Aslam there appears to be a SPAM reply. inform administrator
The spam message has been deleted.
Thus when you see a spam message or a message out of charter, use the "Report" link near the message to indicate it to us.
Thanks by advance :)
Aslam there appears to be a SPAM reply. inform administrator
The spam message has been deleted.
Thus when you see a spam message or a message out of charter, use the "Report" link near the message to indicate it to us.
Thanks by advance :)
24 Oct 2011 à 01:06
Thank you very much for the solving this problem. The macro you have write its working. Just need one amendment in this, that the macro will work only on sheet1 of workbook "Records" not on all open workbooks.
24 Oct 2011 à 01:27
When I run this macro first time I just noticed that one blank line is there between record of each months data and all other blank lines deleted. but after it I noticed that its deleting last row of the months which contain data. please check it and make sure that it will not delete any row which contain data.
Thank you
24 Oct 2011 à 02:15
I am very sorry that I have write above message to you in hustle. Actually the macro is deleting first two rows only all other working is good.