Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Need help creating a simple macro

I need to make a macro that will go through a column of data and looks for a
specific word, when it finds that word it should copy the data from the cell
directly to the right of it and make a list.

Example (2 columns the word "employee" is in one and the name is in another)

Start with this:

Employee Name1
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row

Employee Name2
random stuff taking up lots of columns along the row

Employee Name3
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row

Employee Name4
random stuff taking up lots of columns along the row

Employee Name5

Employee Name6

and I want just this:

Name1
Name2
Name3
Name4
Name5
Name6

There is a varying number of rows between each employee so I don't think a
formula would work. I want the macro to look for every instance of the word
"employee" and give me just a list of names on a new sheet. Is this
possible? Could this be done with a formula instead?
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Need help creating a simple macro

this assumes the word employee is in column a and the name is in column b
and you want the results listed in column c


Option Explicit
Sub find_employee()
Dim rng As Range
Dim lastrow As Long
Dim firstrow As Integer
Dim cell As Range
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Set rng = Range("a1:a" & lastrow)
firstrow = 1

For Each cell In rng.Cells
If UCase(cell.Value) = "EMPLOYEE" Then
Range("c" & firstrow).Value = cell.Offset(0, 1).Value
firstrow = firstrow + 1
End If

Next cell

End Sub


--


Gary


"Dorn" wrote in message
...
I need to make a macro that will go through a column of data and looks for
a
specific word, when it finds that word it should copy the data from the
cell
directly to the right of it and make a list.

Example (2 columns the word "employee" is in one and the name is in
another)

Start with this:

Employee Name1
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row

Employee Name2
random stuff taking up lots of columns along the row

Employee Name3
random stuff taking up lots of columns along the row
random stuff taking up lots of columns along the row

Employee Name4
random stuff taking up lots of columns along the row

Employee Name5

Employee Name6

and I want just this:

Name1
Name2
Name3
Name4
Name5
Name6

There is a varying number of rows between each employee so I don't think a
formula would work. I want the macro to look for every instance of the
word
"employee" and give me just a list of names on a new sheet. Is this
possible? Could this be done with a formula instead?



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
Creating a simple drawing using Excel T5fingersWhite Excel Discussion (Misc queries) 2 January 25th 10 03:44 PM
Need help creating a simple (?) SUM formula! sandres74 Excel Discussion (Misc queries) 4 January 8th 10 01:26 PM
Creating a Simple macro Gunti Excel Discussion (Misc queries) 8 December 16th 08 03:41 PM
Creating a simple chart Keith Charts and Charting in Excel 1 September 1st 08 05:43 PM
Creating what should be a simple macro Dwight Excel Discussion (Misc queries) 6 April 13th 07 06:38 PM


All times are GMT +1. The time now is 02:40 PM.

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"