View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jeannie v jeannie v is offline
external usenet poster
 
Posts: 127
Default Macro with Variable Data

Hi Ariel:

I'm sorry....I don't know what I'm doing wrong, but the macro doesn't
work.....could I send the workbook to you so you can see what happens when I
run the macro? It will pop the first incident of the specialist on the
Worksheet, but the rest of the incidents for that specialist pop further down
on the page.

Any help you can provide would be appreciated.
--
jeannie v


"AD108" wrote:

Glad I could help,

Thanks

Ariel

"jeannie v" wrote in message
...
Hi Ariel:

I apologize...I was doing something wrong.....I found my error and you
last
response worked beautifully, I think...I haven't copied it for all the
specialists yet...But I see that Ebony is working just as it's supposed
to.

I can't tell you how much I appreciate your talents and your help.

Thank you,
--
jeannie v


"Ariel Dugan" wrote:

Sorry,

I am a novice myself. Here is code that works properly, I hope. Notice
I
got rid of that J variable, and instead am just checking in "A4" is blank
to
decide where to start the pasting, and had to activate the "Ebony G"
sheet in
the "Else" section of the "If" structure.

Seems to work now. Let me know.

Sub GetData()
Dim n As Integer, i As Integer
Dim rng As Range



Sheets("Daily Attendance").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Daily Attendance").Activate
If Cells(i, "A").Value = "Glover, Ebony" Then
Range("A" & i & ":L" & i).Copy
Sheets("Ebony G").Activate
If Range("A4") = "" Then
Set rng = Worksheets("Ebony G").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

Else
Sheets("Ebony G").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Ebony G").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i

End Sub

"jeannie v" wrote:

Good Morning, Ariel:

We are getting so close I can taste it.....It works so far for Ebony
except
that the first line of data extracted is pasted where it's supposed to
be,
but the other lines paste at the bottom of my spreadsheet with blank
lines in
between....I want the data lines that are extracted to appear on "Ebony
G"
worksheet right underneath each other with no blank lines. How can we
do
that?
--
jeannie v


"Ariel Dugan" wrote:

Hi Jeannie,

This worked for me.

Sub GetData()
Dim n As Integer, i As Integer, j As Integer
Dim rng As Range

j = 0

Sheets("Daily Attendance").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Daily Attendance").Activate
If Cells(i, "A").Value = "Glover, Ebony" Then
Range("A" & i & ":L" & i).Copy
Sheets("Ebony G").Activate
If j = 0 Then
Set rng = Worksheets("Ebony G").Range("A4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
j = j + 1
Else
n = Cells(Rows.Count, "A").End(xlUp).Row + 1
Set rng = Worksheets("Ebony G").Range("A" & n)
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End If
End If
Next i



End Sub



"jeannie v" wrote:

Hi Ariel: Me again...What can I add to the macro to Paste Special
Values
when it pops in worksheet 1?
--
jeannie v


"Ariel Dugan" wrote:

Did you want the next four lines down?

If so, then replace this line

Range("A" & i & ":L" & i).copy

with this line

Range("A" & i & ":L" & i +4).copy

and that should work.

HTH
Ariel

"jeannie v" wrote:

Hi: I apologize that I am a real novice in Macros.

This is the macro that works great, but I want to tweak it just
a little.

Sheets("Daily Attendance").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
If Cells(i, "A").Value = "Glover, Ebony" Then
v = Cells(i, "C").Value
Exit For
End If
Next
Sheets("Ebony G").Activate
Range("N21").Value = v


I want to create a macro to do almost the same thing, except I
want it to
retrieve more than 1 field of data for the person...Can I tweak
this one to
do what I want?

I want it to say say: If "Glover, Ebony" is found by
auto-filter in Column A
from Cell A2:A160 in Agent Login-Logout, Take the data in
Column A through
Column L and copy to Worksheet 1 "Ebony G" in Cells A4 to L14.

Any help would be appreciated.
--
jeannie v