View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
jeannie v jeannie v is offline
external usenet poster
 
Posts: 127
Default Need to fix macro to list data underneath each other

Hi :
I want this macro to give me the data in Columns B & C of a particular
person in Column A on "Transactions" Worksheet and enter in it Q4 and R4 on
the Named Worksheet. What happens is that it doesn't list all of the
transactions for that person one underneath the other in Q4 and R4....it
enters the first transaction in Q4 & R4 but the just enters the last
transaction in Q44 & R44...with no transactions in between or underneath each
other.

Can someone help with this problem:

Sub Transactions()
'
' Transactions Macro
' Macro recorded 6/23/2007 by Jeannie Vincovich
'
' Keyboard Shortcut: Ctrl+n
'
Dim n As Integer, i As Integer
Dim rng As Range



Sheets("Transactions").Activate
n = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To n
Sheets("Transactions").Activate
If Cells(i, "A").Value = "Jane Doe" Then
Range("B" & i & ":C" & i).Copy
Sheets("Jane D").Activate
If Range("Q4") = "" Then
Set rng = Worksheets("Jane D").Range("Q4")
rng.Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False

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

End If
End If
Next i


End Sub


--
jeannie v