automatically delete empty rows when transfer data from userform to sheet1

abdelfattah

Well-known Member
Joined
May 3, 2019
Messages
1,507
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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
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,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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