Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to sort/delete rows

Hello-

In a nutshell I am trying to figure out how to automatically sort name
and delete blank cells. Here is what I am doing...

I made a simple mock-up of the type of Excel data I am working wit
(below). It contains employee ID number, names, gross pay and wher
each employee did work for the month. The employee information i
entered in the excel sheet, along with each location they did work fo
during the month.

[image: http://www.vidbusters.com/media/excel_sample1.jpg]

This data is then brought to the following sheet through some simple I
statements (basically, if they did work for Location 1, then put th
amount there...).

[image: http://www.vidbusters.com/media/excel_sample2.jpg]

The problem is that when an employee does not do work for a certai
location, it just leaves a blank space. And in the real sheet, ther
are hundreds of employees so the page will have a few employees,
bunch of blank rows, then a few more employees.

I only know enough Excel to get by, my knowledge basically caps of
with VLOOKUPS :) Is there code or some sort of a macro that ca
delete those unused cells and sort the names so they are right unde
each other? If anyone could help, that would be awesome! Thanks i
advance

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Code to sort/delete rows

I created a sample worksheet with blank rows interspersed among the data
rows. Simply using DataSort put all my data in ascending order with all
the blank spaces at the bottom. Is this useful to you?

Ed

"doublef " wrote in message
...
Hello-

In a nutshell I am trying to figure out how to automatically sort names
and delete blank cells. Here is what I am doing...

I made a simple mock-up of the type of Excel data I am working with
(below). It contains employee ID number, names, gross pay and where
each employee did work for the month. The employee information is
entered in the excel sheet, along with each location they did work for
during the month.

[image: http://www.vidbusters.com/media/excel_sample1.jpg]

This data is then brought to the following sheet through some simple IF
statements (basically, if they did work for Location 1, then put the
amount there...).

[image: http://www.vidbusters.com/media/excel_sample2.jpg]

The problem is that when an employee does not do work for a certain
location, it just leaves a blank space. And in the real sheet, there
are hundreds of employees so the page will have a few employees, a
bunch of blank rows, then a few more employees.

I only know enough Excel to get by, my knowledge basically caps off
with VLOOKUPS :) Is there code or some sort of a macro that can
delete those unused cells and sort the names so they are right under
each other? If anyone could help, that would be awesome! Thanks in
advance.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Code to sort/delete rows

This rudimentary code will loop through your worksheet and
delete blank rows. It will leave the blank rows after
the "Total" lines.

Sub DelBlankRows()
Application.ScreenUpdating = False
Dim NumRows As Integer
Dim Iloop As Integer
NumRows = Range("A65536").End(xlUp).Row
For Iloop = 1 To NumRows
If Cells(Iloop, 1) = "" Then
If UCase(Cells(Iloop - 1, 1)) < "TOTAL" Then
Rows(Iloop).Delete
End If
End If
Next Iloop
End Sub

-----Original Message-----
Hello-

In a nutshell I am trying to figure out how to

automatically sort names
and delete blank cells. Here is what I am doing...

I made a simple mock-up of the type of Excel data I am

working with
(below). It contains employee ID number, names, gross

pay and where
each employee did work for the month. The employee

information is
entered in the excel sheet, along with each location they

did work for
during the month.

[image:

http://www.vidbusters.com/media/excel_sample1.jpg]

This data is then brought to the following sheet through

some simple IF
statements (basically, if they did work for Location 1,

then put the
amount there...).

[image:

http://www.vidbusters.com/media/excel_sample2.jpg]

The problem is that when an employee does not do work for

a certain
location, it just leaves a blank space. And in the real

sheet, there
are hundreds of employees so the page will have a few

employees, a
bunch of blank rows, then a few more employees.

I only know enough Excel to get by, my knowledge

basically caps off
with VLOOKUPS :) Is there code or some sort of a macro

that can
delete those unused cells and sort the names so they are

right under
each other? If anyone could help, that would be awesome!

Thanks in
advance.


---
Message posted from http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to delete rows giving mismatch error seed Excel Discussion (Misc queries) 8 March 4th 09 10:31 PM
sort and delete rows of information jlclyde Excel Discussion (Misc queries) 4 November 6th 08 04:29 PM
VBA code to delete rows Secret Squirrel Excel Discussion (Misc queries) 3 January 21st 07 03:01 PM
how can you sort a list to delete blank rows ? Irishimp23 Excel Discussion (Misc queries) 3 February 23rd 06 11:21 PM
code to delete rows ianalexh Excel Discussion (Misc queries) 5 May 5th 05 10:46 AM


All times are GMT +1. The time now is 03:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"