hi all
I have an excel problem that I hope you can help me out with...
I have a code to Inserting blank row after every row with data
I try to find out how to skip any row with an empty cell but I could'tHTML Code:
Thanks in advance !!
hi all
I have an excel problem that I hope you can help me out with...
I have a code to Inserting blank row after every row with data
I try to find out how to skip any row with an empty cell but I could'tHTML Code:
Thanks in advance !!
I am little confused about requirement. Try this if you are looking for that.
Add this line :
After this line :![]()
R = R + 1
![]()
Rows(R).Insert Shift:=xlDown
First of all thank you for your time , but again,
I have a data in range (b8 ) to last used cell in column b
all cells with data expect some cells say : b15 b25 b27 b30
i need to Insert a blank row after every cell with data and skip any empty cell
Any suggestions ?
Ok. Then replace this line :
With this line :![]()
Rows(R).Insert Shift:=xlDown
![]()
Rows(R + 1).Insert Shift:=xlDown
sorry mr.sanram
it's stopping at the first empty cell
Hope it is clear
May be you are doing something wrong. Here is entire code. Just copy and paste this. Then let me know what happened there.
![]()
Sub Mokhtar_Inserting_blank_row_after_every_row_with_data() Dim R As Long, Fr As Long, Lr As Long With Application .Calculation = xlCalculationManual .ScreenUpdating = False .EnableEvents = False .DisplayAlerts = False End With Fr = ActiveSheet.Range("B8").Offset(1).Row Lr = ActiveSheet.Range("B8").End(xlDown).Row For R = Lr To Fr Step -1 If Application.WorksheetFunction.CountA(Rows(R)) > 0 Then Rows(R + 1).Insert Shift:=xlDown End If Next R With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True .EnableEvents = True .DisplayAlerts = True End With End Sub
Hi mr.sanram,
Tested it out! It works like a charm!
Just a point :
I replaced Fr = ActiveSheet.Range("B8").Offset(1).Row
with
Fr = ActiveSheet.Range("B8").Row
Thank you very much for all this great help and for your patience with me
Have a good day from egypt.
Regards
You are welcome.
sorry mr.sanram
I tested the code again
if all cells are full with data it works for me and adds 1 empty row
if any cell is empty it works for me and adds 1 empty row after any empty cell
Please see the attached file for more details.
I'm sorry again
Then you want to remove the empty row, not to skip. Anyway. Here is the code for that :
![]()
Sub test() ' Inserting blank row after every row with data ,kip any row with an empty cell Dim R As Long, Fr As Long, Lr As Long With Application .Calculation = xlCalculationManual .ScreenUpdating = False .EnableEvents = False .DisplayAlerts = False End With Fr = ActiveSheet.Range("B8").row Lr = ActiveSheet.Range("B" & Rows.Count).End(xlUp).row For R = Lr To Fr Step -1 If Application.WorksheetFunction.CountA(Rows(R)) > 0 Then Rows(R + 1).Insert Shift:=xlDown Else Rows(R).EntireRow.Delete End If Next R With Application .Calculation = xlCalculationAutomatic .ScreenUpdating = True .EnableEvents = True .DisplayAlerts = True End With End Sub
Hi mr.sanram,
it works exactly as i hoped
Thank you veryyyyyyyyyyyyyyyyy much for your patience, time and solution, really appreciated.
Regards
Mokhtar
You are welcome.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks