Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting cells in Excel with VB

Status
Not open for further replies.

camidon

Programmer
May 9, 2000
268
US
I have a spreadsheet that has a bunch of unneeded cells at the top of the sheet that I don't need to be there. What I would like to do is create a macro that will clear the cells and then move all of my data up to the very first cell. If I need VB code to do this I'm okay with that. In fact, I'd rather do it that way.

Thanks in advance for the help

Chris
 
Hi,

I read your post to mean that you cannot just delete a block of entire rows that contain the unnecessary cells. If so, what are the criteria for cells to be unnecessary? Or, does the range with your "real" data always start with a specific label? In short what distinguises unnecessary cells from your data cells? And if a cell is unnecessary, can the entire row with that cell be deleted?

IS
 
Couple of options :
1) Delete the rows.
2) Cut and paste all valid data to the new row record.

Unless I'm missing something, such as having to delete the unneeded cells many times per day, I don't think writing VB code to do this is worth the trouble.
 
This is just one step in a series of steps to get what I need out of several sheets and into one shee. This is a "report" that is pushed to Excel because the application is unable to Export into Access. Basically, the cells that I need to delete are the heading of this report. Basically I just need to delete the first 11 rows. No other criterea, just delete the first 11 rows.

Thanks guys, sorry I wasn't very clear

Chris
 
Hi Chris,

Workbooks("BookName").Worksheets("SheetName").Rows("1:11").Delete

should do the job.
Replace the qualifications as needed, e.g. ActiveWorbook.ActiveSheet instead of the full shebang with names.
When the rows are deleted, your data "move up".

Ciao,

Ilse

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top