Hello, I am a newbie to VBA and I know I will make some people cringe when you read my code. I am trying to set up a macro that will copy data from a input workbook, paste into an application, then paste into another output workbook.
I am trying to take baby steps for now, I need to set up the part where I can take data from a spreadsheet thats populated in columns A:F, and a variable number of rows.
I want the macro to start on cell A2 and work its way to F2, then move to the next row, etc (The paste in application and paste into output file I will handle later)
I think I am hitting trouble in 2 areas:
1) setting up the declarations
2) the intersect (If (R,C) is in Col A, I need to paste it into a particular field in the application, same for each other column)
Sub test()
Dim LastRow As Long, LastCol As Integer, c As Integer, r As Long
Set Office = Columns("A")
Set Account = Columns("B")
Set AT = Columns("C")
Set Journal = Columns("D")
Set Sign = Columns("E")
Set Desc = Columns("F")
LastRow = ActiveSheet.UsedRange.Rows(ActiveSheet.UsedRange.Rows.Count).Row
LastCol = ActiveSheet.UsedRange.Columns(ActiveSheet.UsedRange.Columns.Count).Column
For r = 1 To LastRow
For c = 1 To LastCol
If Intersect(Cells(r, c), Office) Then
'Paste into application
'Paste into output
End If
If Intersect(Cells(r, c), Account) Then
'Paste into application
'Paste into output
End If
If Intersect(Cells(r, c), AT) Then
'Paste into application
'Paste into output
End If
If Intersect(Cells(r, c), Journal) Then
'Paste into application
'Paste into output
End If
If Intersect(Cells(r, c), Sign) Then
'Paste into application
'Paste into output
End If
If Intersect(Cells(r, c), Desc) Then
'Paste into application
'Paste into output
End If
c = c + 1
Next c
r = r + 1
Next r
End Sub
Any help would be greatly appreciated!
Bookmarks