Hi Socratis:
I have a problem....it won't pop the value in "C" on the Named Sheet.....I'm
using the first option you suggested since the 2nd option won't work....C
will always have a value and cannot be empty...the data is pulled at once
from another app and planted on the Daily Attendance sheet.
This is exactly what I did to modify the macro you recommended....could you
tell me what I'm dong wrong? I have checked and rechecked every naming
convention on the Daily Attendance sheet to be sure they are correct. When I
run the macro, I get an error message : Run Time Error 9 Subscript out of
range.....Remember that I am really new at macros and I know that you are
extremely sophisticated with them.......Thank you so much for all your help
and your patience....
Public Sub FillNames()
Sheets("Daily Attendance").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
With Cells(i, "A")
If .Value = "Perez, Arnaldis" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Johnson1, David" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Diaz 1, Henry" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Lafleur, Kimberlyn" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Wyatt1, Mariya" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Gonzalez, Merita" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Moyers1, Ricardo" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
ElseIf .Value = "Kelly, Robert" Then
Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
End If
End With
Next
End Sub
--
jeannie v
"Socratis" wrote:
> jeannie,
>
> Here are two versions of the edited macro that do what you want.
>
> 1) Here you check against each name and if present in the Daily Attendance
> sheet, then you update n21 on their named sheet. Note however, that there is
> some redundancy in the code, not to mention that if you have a lot of names,
> then you would have to type quit a few if statements.
>
> Public Sub FillNames()
> Sheets("Daily Attendance").Activate
> n = Cells(Rows.Count, "A").End(xlUp).Row
> For i = 1 To n
> With Cells(i, "A")
> If .Value = "name1" Then
> Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
> ElseIf .Value = "name2" Then
> Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
> ElseIf .Value = "name3" Then
> Sheets(.Value).Range("n21").Value = Cells(i, "C").Value
> End If
> End With
> Next
> End Sub
>
> thus, choice 2 which is shorter and does not require that you enter an if
> for each name. In this version you must include all the names in the
> attendance sheet, by leave the cell in column c empty.
>
> Public Sub FillNames()
> Dim lastRow As Integer
>
> With Sheets("Daily Attendance")
> lastRow = .Cells(Rows.Count, "A").End(xlUp).Row
> End With
>
> For i = 1 To lastRow
> With Sheets("Daily Attendance").Cells(i, "C")
> If Not IsEmpty(.Value) Then
> Sheets(.Offset(0, -2).Value).Range("n21").Value = .Value
> End If
> End With
> Next
> End Sub
>
> HTH.
>
> Cheers,
> Socratis
>
> "jeannie v" wrote:
>
> > Hi:
> >
> > This is my macro that I need to fix....If the person does not have any data
> > on the "Daily Attendance" worksheet, I want it to skip that person's data on
> > their named worksheet....In other words, if Craig doesn't have anything on
> > Daily Attendance, I want it to go to the next worksheet and put the correct
> > data in for that person.....I hope this makes sense.......Any help would be
> > appreciated......
> >
> > Sheets("Daily Attendance").Activate
> > n = Cells(Rows.Count, "A").End(xlUp).Row
> > For i = 1 To n
> > If Cells(i, "A").Value = "Lavendar, Craig" Then
> > v = Cells(i, "C").Value
> > Exit For
> > End If
> > Next
> > Sheets("Craig L").Activate
> > Range("N21").Value = v
> > Sheets("Daily Attendance").Activate
> > n = Cells(Rows.Count, "A").End(xlUp).Row
> > For i = 1 To n
> > If Cells(i, "A").Value = "Blackmon, Jack" Then
> > v = Cells(i, "C").Value
> > Exit For
> > End If
> > Next
> > --
> > jeannie v