Lil Stinker
Board Regular
- Joined
- Feb 16, 2022
- Messages
- 142
- Office Version
- 2019
- Platform
- Windows
I stink at understanding VBA For Loops so maybe you can help me. I'm looking for a way to record/copy quantities on Sheet1: Column I, Rows 10:16 and Column Q, Rows 10:16 to Sheet2: Columns I:V, End xlUp.Row (next available row).
Below is what I have been trying to make work but the first thing that goes wrong is the data transfers to the wrong starting column on Sheet2. It should start in Column I but it drops the data into H instead. The second issue is dealing with the second column on Sheet1... I don't know enough to even know where to begin with that issue. So far, the existing For Loop transfers data just not to the right location. I tried adding another For Loop after the first to account for the second column's quantities but that just negated the first For Loop... and still copied the data into the wrong columns.
I'd appreciate any knowledge you can pass my way. If you need more specifics, please let me know.
Below is what I have been trying to make work but the first thing that goes wrong is the data transfers to the wrong starting column on Sheet2. It should start in Column I but it drops the data into H instead. The second issue is dealing with the second column on Sheet1... I don't know enough to even know where to begin with that issue. So far, the existing For Loop transfers data just not to the right location. I tried adding another For Loop after the first to account for the second column's quantities but that just negated the first For Loop... and still copied the data into the wrong columns.
VBA Code:
Sub RA_SaveRecord()
Dim raROW As Long, equipROW As Long
With Sheet1
If .Range("AB4").Value = True Then
raROW = Sheet2.Range("A10001").End(xlUp).Row + 1
.Range("Q4").Value = .Range("AB6").Value
Sheet2.Range("B" & raROW).Value = .Range("Q4").Value
End If
For equipROW = 10 To 16
Sheet2.Cells(raROW, equipROW - 2).Value = .Range("I" & equipROW).Value 'add quantities
Next equipROW
End With
End Sub
I'd appreciate any knowledge you can pass my way. If you need more specifics, please let me know.