automatically delete empty rows when transfer data from userform to sheet1

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,429
Office Version
  1. 2019
  2. 2010
Platform
  1. Windows
hi, everyone
i need code automatically delete empty rows when transfer data from userform to sheet1
i have userform when i fill data it does transfer data to sheet1 i would delete rows from after lastrow contains data without effect the values of others cells the basic of range beginning from a19:e35 in my case when i fill data in range from a19:e22 after this should delete from a23 :e30 don't delete range a33:e35 because linked of value other lastrow contains data in this case rows a22:e22
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
This checks what is the last row in column A above row 33, so lr =22 and then delete the range (A23:E32)
Code:
[COLOR=#222222][FONT=Verdana]Dim lr As Long: lr = Cells(33, "A").End(xlUp).Row  [/FONT][/COLOR][COLOR=#008000][FONT=Verdana]'Last Row[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]Range("A" & lr + 1, "E32").Delete[/FONT][/COLOR]
 
Last edited:
Upvote 0
This checks what is the last row in column A above row 33, so lr =22 and then delete the range (A23:E32)
Code:
[COLOR=#222222][FONT=Verdana]Dim lr As Long: lr = Cells(33, "A").End(xlUp).Row  [/FONT][/COLOR][COLOR=#008000][FONT=Verdana]'Last Row[/FONT][/COLOR]
[COLOR=#222222][FONT=Verdana]Range("A" & lr + 1, "E32").Delete[/FONT][/COLOR]

i fill in data in userform
the first picture
the second picture what i want
https://ibb.co/x36PTcb
x36PTcb

https://ibb.co/Wn2LL7w
 
Last edited:
Upvote 0
Code:
[FONT=Verdana][I]Dim lr As Long: lr = Cells(33, [COLOR=#ff0000]"C"[/COLOR]).End(xlUp).Row  [/I][/FONT][COLOR=#008000][COLOR=#008000][FONT=monospace][I][FONT=Verdana]'Last Row[/FONT][/I][/FONT][/COLOR][/COLOR][LEFT][COLOR=#333333][FONT=monospace][/FONT][/COLOR][/LEFT]
[COLOR=#222222][LEFT][COLOR=#222222][FONT=monospace][I][FONT=Verdana]Range("A" & lr + 1, "E32").Delete[/FONT][/I][/FONT][/COLOR][/LEFT]
[/COLOR]
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,490
Members
448,967
Latest member
visheshkotha

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top