Delete entire row of data in Excel sheets

Rizana

Board Regular
Joined
Jul 7, 2006
Messages
105
I'm working on a simple program that enabled the user to insert and delete data. The user will insert the data via VBE forms and will be saved in an Excel sheet.

The problem is that, I don't know what is the right VB codes to execute the actions?

I tried to use this code, but it doesn't seems to work.
Code:
Sheet12.Rows(i).EntireRow.Delete = True

Any ideas?
Thanks in advanced
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,882
Office Version
  1. 365
Platform
  1. Windows
If your sheet's name is "sheet12", and assuming that your "i" is a declared integer, then:
Code:
Sheets("sheet12").Rows(i).EntireRow.Delete
...should work.

If your sheet is the 12th sheet in a series, but called something else, then
Code:
Sheets(12).Rows(i).EntireRow.Delete
...should work.
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
Hi Sykes,

if the sheet's code name is Sheet12 then
Code:
Sheet12.Rows(i).EntireRow.Delete
will work.
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,882
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

Hi Glenn

Yes, you got there before me, didn't mean to post over you.
Also thanks for that - I've learnt something else there.

Regards
 

Rizana

Board Regular
Joined
Jul 7, 2006
Messages
105
Thanks a lot

Hello Sykes n GlennUK,

Thank you sooo much for the solution. I'm not familiar with this language and everything seems so hard for me even for an easy problem like this.

Thank you soo much.

Regards,
Rizana
 

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,882
Office Version
  1. 365
Platform
  1. Windows
It's a pleasure
I'm self-taught, and as you can see from my earlier post, am still learning all the time!!
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
My pleasure too. I am also self-taught, and am still learning after many many years of working with Excel and VBA.
 

Forum statistics

Threads
1,141,011
Messages
5,703,724
Members
421,311
Latest member
tanujath

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
Top