![]() |
importing data
Hi! I am trying to import transaction data to an excel cash report file. I
need the macro to first meet 2 conditions for an account number and that it is not miscellaneous. I got so far. Then, ones it determines that it is a valid transaction, i want it to copy and paste the row with the transaction data from the file to my report excel spreadsheet. However, for some reason, I imports the same row over and over again. I need it to go down the list. Please help. Sub Macro1() ' Macro1 Macro ' Macro recorded 7/25/2006 by sdziamchuk ' Dim cell As Range Dim str As String Windows("experiment cahs trans.csv").Activate For Each cell In Range("a2:a30") If cell = 272244 And cell.Offset(0, 1) < "MISCELLANEOUS" Then ActiveCell.Offset(2, 0).Range("A1:L1").Select Selection.Copy Windows("Book2").Activate ActiveCell.Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown ElseIf Not IsEmpty(cell.Value) Then ActiveCell.Offset(1, 0).Activate End If Next cell End Sub -- Sergei D |
importing data
Sergei,
Try the macro below. HTH, Bernie MS Excel MVP Sub TryNow() Dim Cell As Range Dim str As String Windows("experiment cahs trans.csv").Activate For Each Cell In Range("a2:a30") If Cell.Value = 272244 And Cell.Offset(0, 1).Value < "MISCELLANEOUS" Then Cell.Offset(0, 2).Range("A1:L1").Select Selection.Copy Windows("Book2").Activate ActiveCell.Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown Windows("experiment cahs trans.csv").Activate End If Next Cell End Sub "Sergei D" wrote in message ... Hi! I am trying to import transaction data to an excel cash report file. I need the macro to first meet 2 conditions for an account number and that it is not miscellaneous. I got so far. Then, ones it determines that it is a valid transaction, i want it to copy and paste the row with the transaction data from the file to my report excel spreadsheet. However, for some reason, I imports the same row over and over again. I need it to go down the list. Please help. Sub Macro1() ' Macro1 Macro ' Macro recorded 7/25/2006 by sdziamchuk ' Dim cell As Range Dim str As String Windows("experiment cahs trans.csv").Activate For Each cell In Range("a2:a30") If cell = 272244 And cell.Offset(0, 1) < "MISCELLANEOUS" Then ActiveCell.Offset(2, 0).Range("A1:L1").Select Selection.Copy Windows("Book2").Activate ActiveCell.Rows("1:1").EntireRow.Select Selection.Insert Shift:=xlDown ElseIf Not IsEmpty(cell.Value) Then ActiveCell.Offset(1, 0).Activate End If Next cell End Sub -- Sergei D |
All times are GMT +1. The time now is 12:28 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com