Reputation: 27
I'm a beginner in using vba code and I need a statement function to make it move to a new columns with a new starting cell output when the row offset of the first columns=1048567 to continue the processing the vba code
If sq(lUser_1, 2) & "" <> sqq(lUser_2) Then
'we found a new combination, output to screen
Range(sStartingCellOutput).Offset(lRowOffset).Resize(, 3).Value = Array(sq(lUser_1, 2), sqq(lUser_2), rTopic.Value)
'increment the counter
lRowOffset = lRowOffset + 1
End If
Upvotes: 1
Views: 171
Reputation:
You need to introduce another variable to take care of the column offset.
dim lColOffset as long
lColOffset = 0
If sq(lUser_1, 2) & "" <> sqq(lUser_2) Then
'we found a new combination, output to screen
Range(sStartingCellOutput).Offset(lRowOffset, lColOffset).Resize(1, 3).Value = _
Array(sq(lUser_1, 2), sqq(lUser_2), rTopic.Value)
'increment the counter
lRowOffset = lRowOffset + 1
if lRowOffset >= Rows.Count then
lRowOffset = 0
lColOffset = lColOffset + 4
end if
End If
I've staggered the column offset by 4. You are putting three values into the rows so this will leave a blank column. Adjust that stagger is you wish.
Upvotes: 2