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!

excel macro help 1

Status
Not open for further replies.

kevinluebb

Programmer
Jan 4, 2002
30
0
0
US
I've got data that is roughly structured like this:


A B C D E
1 AAAA AAAAA AAAAA AAAAAA AAAA
2 BBBB BBBBBB BBBBB BBBBBB BBBB
3 BBBB
4 CCC CCCCC CCCC CCCCC CCC
5 CCC CCCCC CCC
6 CCCC

I need to be able to sort this data but as you
can see I would lose the relationship for the
data in E3.
What I need to do is check A3 for data, if blank
slide over to E3 and see if it has data. If there
is something in E3, I would need to move it to F3.
I'm not familiar with Excel macros and worked in
Lotus macros many moons ago.
 
Hi,

How do you want to sort your data? Skip,
metzgsk@voughtaircraft.com
 
It would be sorted by column A. So as you can see the data in E before the sort would be lost after the sort.
 
WHAT?

If I sort on A, my resulting rows would be...
1
2
4
5
3
6

Is that NOT what you want? Skip,
metzgsk@voughtaircraft.com
 
Kevin,

The data on each of the rows will be maintained together, PROVIDING that you specify the entire range as your sort range - i.e. highlight columns A to E.

If you do this, I can't see how the data in Column C can be "lost" after the sort.

I hope this helps. If for some reason you are still having problems, perhaps the best option is to email an example of your file, and I'll return it with the code for sorting.

Regards, ...Dale Watson dwatson@bsi.gov.mb.ca
 
Dale,
He has a similar question in the VBA forum. That one seems to be more current. Skip,
metzgsk@voughtaircraft.com
 
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/1/02 by ISD
Range("a1").Select
For i = 1 To 30
ActiveCell.Offset(1, 0).Activate
If ActiveCell.Offset(0, 0).Value = "" Then
ActiveCell.Offset(-1, 9).Value = ActiveCell.Offset(-1, 9).Value + " " + ActiveCell.Offset(0, 8).Value
Selection.EntireRow.Select
Selection.EntireRow.Delete
ActiveCell.Offset(-1, 0).Activate
End If
Next i
End Sub


Never mind....this works. i've only set it for 30 reps for the test but will add a routine to check for the last row.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top