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
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

sykes

Well-known Member
Joined
May 1, 2002
Messages
1,758
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,402
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,758
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,758
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,402
My pleasure too. I am also self-taught, and am still learning after many many years of working with Excel and VBA.
 

Watch MrExcel Video

Forum statistics

Threads
1,113,861
Messages
5,544,721
Members
410,630
Latest member
JFORTH97
Top